Autologin (#186)

* Update get_boot_cli

The default target is graphical.target, whether or not a desktop is
available. Check whether lightdm is enabled as well.

* Remove legacy autologin cruft

* Run systemctl daemon-reload after boot behaviour changes

* Make autologin changes quieter
This commit is contained in:
XECDesign 2022-03-18 15:51:42 +00:00 committed by GitHub
parent 684fbe183a
commit f2ed068292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 20 deletions

6
debian/changelog vendored
View File

@ -1,6 +1,10 @@
raspi-config (20220307) UNRELEASED; urgency=medium
raspi-config (20220318) UNRELEASED; urgency=medium
* Remove nonint whiptail msgbox in do_overlayfs
* Update get_boot_cli
* Remove legacy autologin cruft
* Run systemctl daemon-reload after boot behaviour changes
* Make autologin changes quieter
-- Serge Schneider <serge@raspberrypi.com> Mon, 07 Mar 2022 09:26:38 +0000

View File

@ -1,4 +1,3 @@
raspi-config /usr/bin
autologin@.service /etc/systemd/system
usr/
etc/

View File

@ -1076,27 +1076,21 @@ disable_raspi_config_at_boot() {
}
get_boot_cli() {
if systemctl get-default | grep -q multi-user ; then
echo 0
else
if [ "$(systemctl get-default)" = graphical.target ] && systemctl is-enabled lightdm > /dev/null 2>&1; then
echo 1
else
echo 0
fi
}
get_autologin() {
if [ $(get_boot_cli) -eq 0 ]; then
# booting to CLI
# stretch or buster - is there an autologin conf file?
if [ -e /etc/systemd/system/getty@tty1.service.d/autologin.conf ] ; then
echo 0
else
# stretch or earlier - check the getty service symlink for autologin
if [ $(deb_ver) -le 9 ] && grep -q autologin /etc/systemd/system/getty.target.wants/getty@tty1.service ; then
echo 0
else
echo 1
fi
fi
else
# booting to desktop - check the autologin for lightdm
if grep -q "^autologin-user=" /etc/lightdm/lightdm.conf ; then
@ -1390,13 +1384,11 @@ do_boot_behaviour() {
if [ $? -eq 0 ]; then
case "$BOOTOPT" in
B1*)
systemctl set-default multi-user.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
systemctl --quiet set-default multi-user.target
rm -f /etc/systemd/system/getty@tty1.service.d/autologin.conf
;;
B2*)
systemctl set-default multi-user.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
systemctl --quiet set-default multi-user.target
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
[Service]
ExecStart=
@ -1405,8 +1397,7 @@ EOF
;;
B3*)
if [ -e /etc/init.d/lightdm ]; then
systemctl set-default graphical.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
systemctl --quiet set-default graphical.target
rm -f /etc/systemd/system/getty@tty1.service.d/autologin.conf
sed /etc/lightdm/lightdm.conf -i -e "s/^autologin-user=.*/#autologin-user=/"
disable_raspi_config_at_boot
@ -1417,8 +1408,7 @@ EOF
;;
B4*)
if [ -e /etc/init.d/lightdm ]; then
systemctl set-default graphical.target
ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
systemctl --quiet set-default graphical.target
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
[Service]
ExecStart=
@ -1436,6 +1426,7 @@ EOF
return 1
;;
esac
systemctl daemon-reload
ASK_TO_REBOOT=1
fi
}