diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart index cdafdabbd6..a20f25819a 100644 --- a/dietpi/dietpi-autostart +++ b/dietpi/dietpi-autostart @@ -92,11 +92,11 @@ _EOF_ systemctl enable amiberry - # - Enable systemd-logind to have a login console ready after exiting AmiBerry from fastboot + # Enable systemd-logind to have a login console ready after exiting Amiberry from fastboot systemctl unmask systemd-logind systemctl enable systemd-logind &> /dev/null - # - Apply tweaks + # Apply tweaks if (( $G_HW_MODEL < 10 )); then G_CONFIG_INJECT 'boot_delay=' 'boot_delay=0' /DietPi/config.txt @@ -109,25 +109,25 @@ _EOF_ # - Enable autologin elif (( $AUTO_START_INDEX > 0 )); then - # - Autologin user, only ask in interactive mode and skip for LightDM, which must be started as root - local user=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_AUTOSTART_LOGIN_USER=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + # Autologin user, only ask in interactive mode and skip for LightDM, which must be started as root + local user=$(sed -n '/^[[:blank:]]*AUTO_SETUP_AUTOSTART_LOGIN_USER=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) if (( $AUTO_START_INDEX == 16 )); then - # - LightDM pre-req check, but install only if xinit (a desktop) is already installed. This is re-applied by dietpi-software after install automatically. + # LightDM pre-req check, but install only if xinit (a desktop) is already installed. This is re-applied by dietpi-software after install automatically. command -v startx &> /dev/null && G_AG_CHECK_INSTALL_PREREQ lightdm user='root' elif (( $INPUT == -1 )); then - # - Only users with ID >= 1000 (+ root) and with valid login shell - G_WHIP_MENU_ARRAY=( 'root' 'UID:0' $(mawk -F: '$3 >= 1000 && $7 ~ /^\/bin\/.*sh$/ {print $1" UID:"$3}' /etc/passwd) ) + # Only users with ID >= 1000 (+ root) and with valid login shell + G_WHIP_MENU_ARRAY=('root' 'UID:0' $(mawk -F: '$3 >= 1000 && $7 ~ /^\/bin\/.*sh$/ {print $1" UID:"$3}' /etc/passwd)) G_WHIP_DEFAULT_ITEM=$user G_WHIP_MENU "Please choose a user to login with. NB: You might need to grant the user permissions to run the chosen autostart option.\n\nCurrent choice: $user" && user=$G_WHIP_RETURNED_VALUE fi - # - Sanity check + # Sanity check if ! grep -qE "^$user:[^:]*:(0|[1-9][0-9][0-9][0-9]+):.*:/bin/[^:]*sh$" /etc/passwd; then G_DIETPI-NOTIFY 1 "User \"$user\" does not exist, is a system user or does not have a valid login shell. Reverting to \"root\"." @@ -135,6 +135,10 @@ NB: You might need to grant the user permissions to run the chosen autostart opt fi + # Apply user choice to dietpi.txt + G_CONFIG_INJECT 'AUTO_SETUP_AUTOSTART_LOGIN_USER=' "AUTO_SETUP_AUTOSTART_LOGIN_USER=$user" /DietPi/dietpi.txt + + # Apply to TTY1 getty mkdir -p /etc/systemd/system/getty@tty1.service.d cat << _EOF_ > /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf [Service] @@ -202,9 +206,9 @@ This mode allows for a < 2.5 second boot on an RPi3, into Amiberry.\n\nIf you ex # Chromium prompt for URL elif (( $AUTO_START_INDEX == 11 )); then - G_WHIP_DEFAULT_ITEM=$(grep -m1 '^[[:blank:]]*SOFTWARE_CHROMIUM_AUTOSTART_URL=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - G_WHIP_INPUTBOX 'Please enter a homepage URL to start with Chromium:\n - eg: https://dietpi.com' - (( $? == 0 )) && G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_AUTOSTART_URL=' "SOFTWARE_CHROMIUM_AUTOSTART_URL=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt + G_WHIP_DEFAULT_ITEM=$(sed -n '/^[[:blank:]]*SOFTWARE_CHROMIUM_AUTOSTART_URL=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + G_WHIP_INPUTBOX 'Please enter a homepage URL to start with Chromium: + - E.g.: https://dietpi.com' && G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_AUTOSTART_URL=' "SOFTWARE_CHROMIUM_AUTOSTART_URL=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt # Custom info elif (( $AUTO_START_INDEX == 14 )); then