From 9a741ded9fb4e93a0e1d6206ec2dd28503db210b Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Mon, 16 Dec 2013 20:55:23 +0000 Subject: [PATCH] fail boot to scratch/boot to desktop if pi user was removed As reported in #30 --- raspi-config | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/raspi-config b/raspi-config index 32f881e..5af1363 100755 --- a/raspi-config +++ b/raspi-config @@ -477,10 +477,14 @@ do_boot_behaviour() { ;; Desktop) if [ -e /etc/init.d/lightdm ]; then - update-rc.d lightdm enable 2 - sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/" - disable_boot_to_scratch - disable_raspi_config_at_boot + if id -u pi > /dev/null 2>&1; then + update-rc.d lightdm enable 2 + sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/" + disable_boot_to_scratch + disable_raspi_config_at_boot + else + whiptail --msgbox "The pi user has been removed, can't set up boot to desktop" 20 60 2 + fi else whiptail --msgbox "Do sudo apt-get install lightdm to allow configuration of boot to desktop" 20 60 2 return 1 @@ -488,9 +492,13 @@ do_boot_behaviour() { ;; Scratch) if [ -e /usr/bin/scratch ]; then - [ -e /etc/init.d/lightdm ] && update-rc.d lightdm disable 2 - disable_raspi_config_at_boot - enable_boot_to_scratch + if id -u pi > /dev/null 2>&1; then + [ -e /etc/init.d/lightdm ] && update-rc.d lightdm disable 2 + disable_raspi_config_at_boot + enable_boot_to_scratch + else + whiptail --msgbox "The pi user has been removed, can't set up boot to scratch" 20 60 2 + fi else whiptail --msgbox "Do sudo apt-get install scratch to allow configuration of boot to scratch" 20 60 2 fi