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 * 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 -- Serge Schneider <serge@raspberrypi.com> Mon, 07 Mar 2022 09:26:38 +0000

View File

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

View File

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