08-08-2018, 01:44 PM
Oh, woops. But look at the source of raspi-config, the autologin parts. https://github.com/RPi-Distro/raspi-config Armbian has something similar, maybe derived from it. You might even be able to copy out the code and make it run, it's just a bash script. Or manually do what the script does.
There are 2 different autologin scenarios for console and GUI. Checking for autologin:
Setting autologin:
That $SUDO_USER gets populated with who runs sudo. If you're already root and you run raspi-config without sudo the user name is an empty string, it doesn't work. But root can run sudo just fine. Except root autologin is blocked elsewhere.
There are 2 different autologin scenarios for console and GUI. Checking for autologin:
Code:
get_autologin() {
if [ $(get_boot_cli) -eq 0 ]; then
# booting to CLI - check the autologin in getty or initd */
if grep -q autologin /etc/systemd/system/getty.target.wants/getty@tty1.servi
ce ; then
echo 0
else
echo 1
fi
else
# booting to desktop - check the autologin for lightdm */
if grep -q "^autologin-user=" /etc/lightdm/lightdm.conf ; then
echo 0
else
echo 1
fi
fi
}
Setting autologin:
Code:
B4*)
if [ -e /etc/init.d/lightdm ]; then
systemctl set-default graphical.target
ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-user=.*/autologin-user=$SUDO_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
return 1
fi
;;
*)
whiptail --msgbox "Programmer error, unrecognised boot option" 20 60 2
return 1