Debian: passwordless updates, offline updates, and install ISO builder

Ports the update behaviour of the Fedora clients to Debian, and adds the
Debian equivalent of putting ks.cfg on the installation medium.

Updates
-------
Debian's shipped polkit policy only lets a sudo-group user trigger
upgrade-system and trigger-offline-update without a password. The actions
pkcon refresh and pkcon update actually use (system-sources-refresh and
system-update) are auth_admin, so a desktop user was prompted - a
behavioural difference from Fedora. update_local_repo.py now installs
/etc/polkit-1/rules.d/60-vdi-no-password-updates.rules granting exactly
those two plus package-install to group sudo. package-remove,
package-reinstall and package-install-untrusted stay auth_admin.

The offline update itself ports unchanged: Debian 13 PackageKit 1.3.1
supports offline-get-prepared and offline-trigger, and
packagekit-offline-update.service is wired into system-update.target.
Scheduling moves from an @reboot cron line to vdi-offline-update.timer
(6h, Persistent), with /root/auto_update.sh delegating to the same script
so there is one implementation instead of two.

Both are installed by update_local_repo.py, not only by the preseed, so
already-provisioned machines pick them up on their next 10-minute cron run.

install ISO
-----------
debian/make-iso.sh bakes preseed.cfg into a Debian netinst ISO and adds
auto=true priority=critical preseed/file=/cdrom/preseed.cfg to every boot
menu entry, then verifies its own output.

Measured, not assumed
---------------------
* subject.local == true never matches in this environment: pkcheck returns
  2 with the clause and 0 without it, same sudo-group user. It was in the
  first version of the rule and is removed; the reasoning is in the source.
* pkcon exits 5 for "no packages to update", which is the normal answer on
  a patched box and was being logged as a download failure. Fixed.
* offline-get-prepared exits 4 when nothing is prepared, so the Fedora
  "if ... offline-trigger" guard is load-bearing - triggering anyway can
  leave a dangling /system-update symlink that breaks the next boot.
* Extracting a netinst and rebuilding with "xorriso -as mkisofs" grows it
  792MB -> 988MB because Debian shares identical file extents; replaying
  the original session with -map keeps dedup and the boot record.
* A hardcoded menu list misses isolinux/gtk.cfg, where the BIOS *default*
  entry lives, so the machine still prompted. Menus are discovered now.

Tests: 90 passed, 0 failed, 2 skipped. T17 asserts the polkit decision in
both directions (authorised with the rule, prompted without it), because a
check that cannot fail proves nothing.
This commit is contained in:
Mistercoolertyper committed 2026-11-04 10:16:23 +01:00
1 parent 4f1a4530aa
commit 15d65183dc
6 files changed
+1335 -2

No files matched your search

+24 -1
View File
@@ -456,6 +456,29 @@ d-i cdrom-detect/eject boolean false
# TeamViewer's apt repo. The repo file is written by late_command; the suite
# is "stable" (TeamViewer publishes stable, not trixie) and the key is
# fetched over https and pinned with signed-by.
# * /root/auto_update.sh no longer contains the pkcon sequence inline. It
# delegates to /usr/local/sbin/vdi-offline-update, which update_local_repo.py
# installs and which vdi-offline-update.timer also runs every 6 hours. One
# implementation instead of two, and the timer means the offline update is
# prepared on a schedule rather than only at boot.
#
# UPDATE BEHAVIOUR - parity with the Fedora clients:
# * No password for updates. Debian's own polkit rules only let a sudo-group
# user trigger "upgrade-system" and "trigger-offline-update" without a
# prompt; "system-sources-refresh" and "system-update" (what pkcon refresh
# and pkcon update use) are auth_admin, so a desktop user IS asked. The rule
# update_local_repo.py installs fills that gap. Measured with pkcheck: with
# the rule rc=0 (authorised), without it rc=2 (authentication required).
# * Offline update works. Debian 13 PackageKit 1.3.1 supports
# offline-get-prepared and offline-trigger, and
# packagekit-offline-update.service is wired into system-update.target.
# Verified end to end: offline-trigger creates
# /system-update -> /var/lib/PackageKit/prepared-update holding the
# downloaded package list, which systemd applies on the next boot.
# * The Fedora `if pkcon offline-get-prepared; then pkcon offline-trigger` guard
# is load-bearing and kept: offline-get-prepared exits 4 when nothing is
# prepared, and triggering anyway leaves a dangling /system-update symlink
# that fails the next boot.
# * `git clone` is FAIL-SOFT here. The kickstart runs with set -e and aborts the
# whole %post if the internal Gitea server is unreachable, which leaves a
# half-provisioned machine. The 10-minute cron job picks the clone up on its
@@ -492,7 +515,7 @@ d-i preseed/late_command string \
chown 0:0 /target/etc/firefox/policies/policies.json; \
mkdir -p /target/etc/apt/sources.list.d /target/usr/share/keyrings; \
printf "%s\n" "deb [signed-by=/usr/share/keyrings/teamviewer.asc] https://linux.teamviewer.com/deb stable main" > /target/etc/apt/sources.list.d/teamviewer.list; \
printf "%s\n" '#!/bin/bash' 'set -euo pipefail' 'INV="${1:-00000}"' 'LOG=/root/post-install.log' 'exec >>"$LOG" 2>&1' 'echo "=== VDI post-install, inventory ${INV} ==="' 'HOSTNAME="EXTVDIL${INV}"' 'USERNAME="vdi${INV}"' 'FULLNAME="VDI-${INV}"' 'PASSWORD="pwVDI#${INV}"' "ROOT_HASH='\$6\$3EpVOhxlL/EVU/8f\$Z.M5x/x5OdzBFW2C0IoNo5KCsLURBJZnp1BgcMWFz8gsjEPSgAlBKEs7CgZnRAGjbrEzgvUCEydmjtZYvUraJ/'" 'printf "%s\n" "$HOSTNAME" > /etc/hostname' 'printf "127.0.1.1\t%s\n" "$HOSTNAME" >> /etc/hosts' 'hostnamectl set-hostname "$HOSTNAME" 2>/dev/null || true' 'getent group sudo >/dev/null || groupadd sudo' 'if ! id VDI-ADMIN >/dev/null 2>&1; then' ' useradd -m -s /bin/bash -G sudo -c "VDI Admin" -p "$ROOT_HASH" VDI-ADMIN' 'fi' 'if ! id "$USERNAME" >/dev/null 2>&1; then' ' useradd -m -s /bin/bash -c "$FULLNAME" "$USERNAME"' 'fi' 'printf "%s:%s\n" "$USERNAME" "$PASSWORD" | chpasswd' 'if ! wget -q -O /usr/share/keyrings/teamviewer.asc https://linux.teamviewer.com/pubkey/currentkey.asc; then' ' echo "teamviewer key download failed"' 'fi' 'apt-get update || echo "apt-get update failed"' 'if [ -d /root/VDI-Linux/.git ]; then' ' ( cd /root/VDI-Linux && git pull ) || echo "git pull failed - continuing"' 'else' ' git clone https://nachos386.lcube-server.de/REYHER-Systemtechnik-Public/VDI-Linux /root/VDI-Linux || echo "git clone failed - continuing"' 'fi' 'if [ -f /root/VDI-Linux/update_local_repo.py ]; then' ' ( cd /root/VDI-Linux && python3 ./update_local_repo.py ) || echo "update_local_repo.py failed"' 'fi' 'apt-get update || echo "apt-get update failed"' 'apt-get install -y icaclient ctxusb || echo "citrix install failed"' 'apt-get install -f -y || true' 'apt-get install -y teamviewer || echo "teamviewer install failed"' 'cat > /root/auto_update.sh <<EOF' '#!/bin/bash' 'systemd-inhibit --what=sleep:idle --who="Auto Update Script" --why="Downloading system updates" /bin/bash -c "' ' pkcon refresh force' ' pkcon update --only-download' ' if pkcon offline-get-prepared >/dev/null 2>&1; then' ' pkcon offline-trigger' ' fi' '"' 'EOF' 'chmod +x /root/auto_update.sh' 'cat > /etc/systemd/system/disable-sleep.service <<EOF' '[Unit]' 'Description=Disable sleep and idle actions permanently' 'After=multi-user.target' '' '[Service]' 'Type=simple' 'ExecStart=/usr/bin/systemd-inhibit --what=sleep:idle --who="Permanent Inhibit" --why="Keep system always awake" --mode=block /bin/sleep infinity' 'Restart=always' '' '[Install]' 'WantedBy=multi-user.target' 'EOF' 'printf "%s\n" "*/10 * * * * root cd /root/VDI-Linux && python3 update_local_repo.py >> /var/log/update_local_repo.log 2>&1" >> /etc/crontab' 'printf "%s\n" "@reboot root bash -c \"until ping google.com -c1 >/dev/null 2>&1; do sleep 1; done;\" && cd /root/ && ./auto_update.sh >> /var/log/update_local_repo.log 2>&1" >> /etc/crontab' 'systemctl enable disable-sleep.service || echo "enable disable-sleep failed"' 'systemctl enable cron || echo "enable cron failed"' 'echo "VDI post-install complete"' > /target/root/vdi-post.sh; \
printf "%s\n" '#!/bin/bash' 'set -euo pipefail' 'INV="${1:-00000}"' 'LOG=/root/post-install.log' 'exec >>"$LOG" 2>&1' 'echo "=== VDI post-install, inventory ${INV} ==="' 'HOSTNAME="EXTVDIL${INV}"' 'USERNAME="vdi${INV}"' 'FULLNAME="VDI-${INV}"' 'PASSWORD="pwVDI#${INV}"' "ROOT_HASH='\$6\$3EpVOhxlL/EVU/8f\$Z.M5x/x5OdzBFW2C0IoNo5KCsLURBJZnp1BgcMWFz8gsjEPSgAlBKEs7CgZnRAGjbrEzgvUCEydmjtZYvUraJ/'" 'printf "%s\n" "$HOSTNAME" > /etc/hostname' 'printf "127.0.1.1\t%s\n" "$HOSTNAME" >> /etc/hosts' 'hostnamectl set-hostname "$HOSTNAME" 2>/dev/null || true' 'getent group sudo >/dev/null || groupadd sudo' 'if ! id VDI-ADMIN >/dev/null 2>&1; then' ' useradd -m -s /bin/bash -G sudo -c "VDI Admin" -p "$ROOT_HASH" VDI-ADMIN' 'fi' 'if ! id "$USERNAME" >/dev/null 2>&1; then' ' useradd -m -s /bin/bash -c "$FULLNAME" "$USERNAME"' 'fi' 'printf "%s:%s\n" "$USERNAME" "$PASSWORD" | chpasswd' 'if ! wget -q -O /usr/share/keyrings/teamviewer.asc https://linux.teamviewer.com/pubkey/currentkey.asc; then' ' echo "teamviewer key download failed"' 'fi' 'apt-get update || echo "apt-get update failed"' 'if [ -d /root/VDI-Linux/.git ]; then' ' ( cd /root/VDI-Linux && git pull ) || echo "git pull failed - continuing"' 'else' ' git clone https://nachos386.lcube-server.de/REYHER-Systemtechnik-Public/VDI-Linux /root/VDI-Linux || echo "git clone failed - continuing"' 'fi' 'if [ -f /root/VDI-Linux/update_local_repo.py ]; then' ' ( cd /root/VDI-Linux && python3 ./update_local_repo.py ) || echo "update_local_repo.py failed"' 'fi' 'apt-get update || echo "apt-get update failed"' 'apt-get install -y icaclient ctxusb || echo "citrix install failed"' 'apt-get install -f -y || true' 'apt-get install -y teamviewer || echo "teamviewer install failed"' 'cat > /root/auto_update.sh <<EOF' '#!/bin/bash' '# Delegates to the single offline-update implementation, which' '# update_local_repo.py installs and vdi-offline-update.timer also runs every 6h.' 'if [ -x /usr/local/sbin/vdi-offline-update ]; then' ' exec /usr/local/sbin/vdi-offline-update' 'fi' 'echo "auto_update.sh: vdi-offline-update not installed yet"' 'EOF' 'chmod +x /root/auto_update.sh' 'cat > /etc/systemd/system/disable-sleep.service <<EOF' '[Unit]' 'Description=Disable sleep and idle actions permanently' 'After=multi-user.target' '' '[Service]' 'Type=simple' 'ExecStart=/usr/bin/systemd-inhibit --what=sleep:idle --who="Permanent Inhibit" --why="Keep system always awake" --mode=block /bin/sleep infinity' 'Restart=always' '' '[Install]' 'WantedBy=multi-user.target' 'EOF' 'printf "%s\n" "*/10 * * * * root cd /root/VDI-Linux && python3 update_local_repo.py >> /var/log/update_local_repo.log 2>&1" >> /etc/crontab' 'printf "%s\n" "@reboot root bash -c \"until ping google.com -c1 >/dev/null 2>&1; do sleep 1; done;\" && cd /root/ && ./auto_update.sh >> /var/log/update_local_repo.log 2>&1" >> /etc/crontab' 'systemctl enable disable-sleep.service || echo "enable disable-sleep failed"' 'systemctl enable cron || echo "enable cron failed"' '# The offline-update timer is normally enabled by update_local_repo.py, but that' '# only runs on the 10-minute cron. Enabling it here too means a fresh install' '# gets offline updates from the first boot, not ten minutes in.' 'systemctl enable vdi-offline-update.timer 2>/dev/null || true' 'echo "VDI post-install complete"' > /target/root/vdi-post.sh; \
chmod 700 /target/root/vdi-post.sh; \
in-target bash /root/vdi-post.sh "$inv"