Skip to content

Commit d293309

Browse files
committed
Fix GUI autologin without tty autologin
Use Raspberry Pi's GUI-only autologin path after first-boot user setup so GUI images do not leave tty1 autologin enabled, and add a pre-post-boot E2E hook point for distros to assert boot state before test setup mutates it. Document the raspi-config do_autologin bitmask so the GUI-only value is clear.
1 parent 27ff1d3 commit d293309

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

src/distro_testing/scripts/entrypoint.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,32 @@ if [ "$SSH_WAIT_RC" -ne 0 ]; then
6363
exit 1
6464
fi
6565

66+
# Run distro-specific boot-state checks before post-boot hooks mutate the image
67+
if [ -x /test/hooks/post-ssh.sh ]; then
68+
echo ""
69+
echo "--- Step 3b: Post-SSH checks ---"
70+
set +e
71+
if [ -n "$ARTIFACTS_DIR" ]; then
72+
/test/hooks/post-ssh.sh localhost "$SSH_PORT" "$ARTIFACTS_DIR"
73+
else
74+
/test/hooks/post-ssh.sh localhost "$SSH_PORT"
75+
fi
76+
POST_SSH_RC=$?
77+
set -e
78+
if [ "$POST_SSH_RC" -ne 0 ]; then
79+
echo "Post-SSH hook failed"
80+
if [ -n "$ARTIFACTS_DIR" ]; then
81+
cp "$LOG_FILE" "$ARTIFACTS_DIR/qemu-boot.log" 2>/dev/null || true
82+
echo "$POST_SSH_RC" > "$ARTIFACTS_DIR/exit-code"
83+
fi
84+
exit "$POST_SSH_RC"
85+
fi
86+
fi
87+
6688
# Run distro-specific post-boot setup (e.g. install packages, restart services)
6789
if [ -x /test/hooks/post-boot.sh ]; then
6890
echo ""
69-
echo "--- Step 3b: Post-boot setup ---"
91+
echo "--- Step 3c: Post-boot setup ---"
7092
/test/hooks/post-boot.sh localhost "$SSH_PORT" || echo "WARNING: post-boot hook failed"
7193
fi
7294

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
#!/bin/bash
2+
set -e
3+
4+
LIGHTDM_CONF=/etc/lightdm/lightdm.conf
5+
TTY1_AUTOLOGIN_CONF=/etc/systemd/system/getty@tty1.service.d/autologin.conf
6+
7+
set_lightdm_option() {
8+
local key="$1"
9+
local value="$2"
10+
11+
if grep -Eq "^#?${key}=" "${LIGHTDM_CONF}"; then
12+
sed -i -E "s|^#?${key}=.*|${key}=${value}|" "${LIGHTDM_CONF}"
13+
else
14+
printf '%s=%s\n' "${key}" "${value}" >> "${LIGHTDM_CONF}"
15+
fi
16+
}
17+
218
if [ ! -f /etc/updated_lightdm_conf ]; then
3-
sed -i 's/UID_1000_PLACEHOLDER/'$(id -nu 1000)'/g' /etc/lightdm/lightdm.conf
19+
gui_user="$(id -nu 1000)"
20+
21+
sed -i "s/UID_1000_PLACEHOLDER/${gui_user}/g" "${LIGHTDM_CONF}"
22+
23+
# raspi-config do_autologin uses a bitmask: 1=TTY, 2=GUI, 3=both.
24+
# FullPageOS needs GUI autologin without opening a local tty shell.
25+
if ! SUDO_USER="${gui_user}" raspi-config nonint do_autologin 2; then
26+
rm -f "${TTY1_AUTOLOGIN_CONF}"
27+
rmdir --ignore-fail-on-non-empty "$(dirname "${TTY1_AUTOLOGIN_CONF}")" 2>/dev/null || true
28+
set_lightdm_option autologin-user "${gui_user}"
29+
fi
30+
31+
set_lightdm_option user-session guisession
32+
set_lightdm_option autologin-session guisession
33+
set_lightdm_option autologin-user "${gui_user}"
34+
35+
systemctl daemon-reload || true
36+
systemctl try-restart getty@tty1.service || true
37+
438
touch /etc/updated_lightdm_conf
5-
# sudo shutdown -r now
639
fi

src/modules/gui/filesystem/root_init/etc/systemd/system/update_lightdm_conf.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[Unit]
22
Description=on first boot set up the user name auto login in lightdm.service
3+
Before=lightdm.service
34
[Service]
45
ExecStart=/opt/custompios/scripts/update_lightdm_conf
56
Type=oneshot

0 commit comments

Comments
 (0)