mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Handle cases where SUDO_USER is unset
This commit is contained in:
parent
2c15bc0cf0
commit
0d5ffcadbe
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
||||
raspi-config (20200109) UNRELEASED; urgency=medium
|
||||
|
||||
* Handle cases where SUDO_USER is unset
|
||||
|
||||
-- Serge Schneider <serge@raspberrypi.org> Thu, 09 Jan 2020 14:38:50 +0000
|
||||
|
||||
raspi-config (20191210) buster; urgency=medium
|
||||
|
||||
* Fix postrm script
|
||||
|
25
raspi-config
25
raspi-config
@ -8,6 +8,8 @@ ASK_TO_REBOOT=0
|
||||
BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
|
||||
CONFIG=/boot/config.txt
|
||||
|
||||
USER=${SUDO_USER:-$(who -m | awk '{ print $1 }')}
|
||||
|
||||
is_pi () {
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
if [ "$ARCH" = "armhf" ] ; then
|
||||
@ -443,8 +445,8 @@ do_pixdub() {
|
||||
}
|
||||
|
||||
do_change_pass() {
|
||||
whiptail --msgbox "You will now be asked to enter a new password for the $SUDO_USER user" 20 60 1
|
||||
passwd $SUDO_USER &&
|
||||
whiptail --msgbox "You will now be asked to enter a new password for the $USER user" 20 60 1
|
||||
passwd $USER &&
|
||||
whiptail --msgbox "Password changed successfully" 20 60 1
|
||||
}
|
||||
|
||||
@ -1105,9 +1107,9 @@ do_boot_behaviour() {
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
BOOTOPT=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
|
||||
"B1 Console" "Text console, requiring user to login" \
|
||||
"B2 Console Autologin" "Text console, automatically logged in as '$SUDO_USER' user" \
|
||||
"B2 Console Autologin" "Text console, automatically logged in as '$USER' user" \
|
||||
"B3 Desktop" "Desktop GUI, requiring user to login" \
|
||||
"B4 Desktop Autologin" "Desktop GUI, automatically logged in as '$SUDO_USER' user" \
|
||||
"B4 Desktop Autologin" "Desktop GUI, automatically logged in as '$USER' user" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
BOOTOPT=$1
|
||||
@ -1126,7 +1128,7 @@ do_boot_behaviour() {
|
||||
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin $SUDO_USER --noclear %I \$TERM
|
||||
ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM
|
||||
EOF
|
||||
;;
|
||||
B3*)
|
||||
@ -1148,9 +1150,9 @@ EOF
|
||||
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin $SUDO_USER --noclear %I \$TERM
|
||||
ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM
|
||||
EOF
|
||||
sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-user=.*/autologin-user=$SUDO_USER/"
|
||||
sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-user=.*/autologin-user=$USER/"
|
||||
disable_raspi_config_at_boot
|
||||
else
|
||||
whiptail --msgbox "Do 'sudo apt-get install lightdm' to allow configuration of boot to desktop" 20 60 2
|
||||
@ -2275,10 +2277,15 @@ do_network_menu() {
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
[ -e $CONFIG ] || touch $CONFIG
|
||||
calc_wt_size
|
||||
while [ "$USER" = "root" ] || [ -z "$USER" ]; do
|
||||
if ! USER=$(whiptail --inputbox "raspi-config could not determine the default user.\\n\\nWhat user should these settings apply to?" 20 60 pi 3>&1 1>&2 2>&3); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
while true; do
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
|
||||
"1 Change User Password" "Change password for the current user" \
|
||||
"1 Change User Password" "Change password for the '$USER' user" \
|
||||
"2 Network Options" "Configure network settings" \
|
||||
"3 Boot Options" "Configure options for start-up" \
|
||||
"4 Localisation Options" "Set up language and regional settings to match your location" \
|
||||
@ -2290,7 +2297,7 @@ if [ "$INTERACTIVE" = True ]; then
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
|
||||
"1 Change User Password" "Change password for the current user" \
|
||||
"1 Change User Password" "Change password for the '$USER' user" \
|
||||
"2 Network Options" "Configure network settings" \
|
||||
"3 Boot Options" "Configure options for start-up" \
|
||||
"4 Localisation Options" "Set up language and regional settings to match your location" \
|
||||
|
Loading…
Reference in New Issue
Block a user