feat: made passwordless system not log out uesr

This commit is contained in:
Krzysztof Rudnicki 2025-08-01 13:19:00 +02:00
parent e53501d217
commit ec47b77847

View File

@ -2,9 +2,31 @@
# Script to set up passwordless sudo and automatic login # Script to set up passwordless sudo and automatic login
# Configures lightdm for auto-login and sudo for passwordless access # Configures lightdm for auto-login and sudo for passwordless access
# Handles sudo privileges automatically # Handles sudo privileges automatically
# Usage: ./setup_passwordless_system.sh [--reboot] [--logout]
# --reboot: Offer to reboot after setup completion
# --logout: Allow restart of LightDM (which will logout the user)
set -e # Exit on any error set -e # Exit on any error
# Check for flags
OFFER_REBOOT=false
ALLOW_LOGOUT=false
for arg in "$@"; do
case $arg in
--reboot)
OFFER_REBOOT=true
shift
;;
--logout)
ALLOW_LOGOUT=true
shift
;;
*)
# Unknown option, keep it for sudo check
;;
esac
done
# Function to check and request sudo privileges # Function to check and request sudo privileges
check_sudo() { check_sudo() {
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -142,10 +164,14 @@ EOF
systemctl enable lightdm.service systemctl enable lightdm.service
echo "✓ LightDM service enabled" echo "✓ LightDM service enabled"
# Restart lightdm to apply changes # Restart lightdm to apply changes only if --logout flag is provided
echo "Restarting LightDM to apply auto-login settings..." if [[ "$ALLOW_LOGOUT" == true ]]; then
systemctl restart lightdm.service echo "Restarting LightDM to apply auto-login settings..."
echo "✓ LightDM restarted" systemctl restart lightdm.service
echo "✓ LightDM restarted"
else
echo "✓ LightDM configuration complete (restart lightdm or reboot to activate auto-login)"
fi
} }
# Function to configure i3 session # Function to configure i3 session
@ -324,15 +350,23 @@ test_configurations
show_security_warnings show_security_warnings
show_final_instructions show_final_instructions
echo "" # Only offer reboot if --reboot flag was provided
echo "Would you like to reboot now to activate all changes?" if [[ "$OFFER_REBOOT" == true ]]; then
read -p "Reboot system now? (y/N): " -n 1 -r echo ""
echo echo "Would you like to reboot now to activate all changes?"
read -p "Reboot system now? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Rebooting system in 5 seconds..." echo "Rebooting system in 5 seconds..."
sleep 5 sleep 5
reboot reboot
else
echo "Remember to reboot when convenient to activate all changes."
fi
else else
echo ""
echo "Setup completed successfully."
echo "Remember to reboot when convenient to activate all changes." echo "Remember to reboot when convenient to activate all changes."
echo "To automatically prompt for reboot in the future, use: $0 --reboot"
fi fi