-
-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ DietPi-Autostart | Save chosen auto login user to dietpi.txt to not have choice reverted via "dietpi-autostart int" calls + DietPi-Autostart | Minor coding
- Loading branch information
Showing
1 changed file
with
15 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,32 +109,36 @@ _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\"." | ||
user='root' | ||
|
||
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/[email protected] | ||
cat << _EOF_ > /etc/systemd/system/[email protected]/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 | ||
|