Files
VDI-Linux/debian/preseed.cfg
T

558 lines
34 KiB
INI
Raw Normal View History

#_preseed_V1
#
# Debian 13 "trixie" preseed - the port of the Fedora kickstart at
# ../../ks.cfg (one directory above this git repo).
#
# This file is the Debian equivalent of ks.cfg. Every block below names the
# kickstart directive it corresponds to, so a maintainer of the Fedora path can
# diff the two side by side. Where Debian's installer (d-i) cannot do what the
# kickstart does, the block says so and explains what is done instead - see
# "GAPS" at the end for the consolidated list.
#
# Directive existence: every "d-i <question>" line below was checked against the
# real template files shipped in the trixie d-i udebs (preseed-common,
# partman-*, netcfg, user-setup-udeb, localechooser, tzsetup, console-setup,
# clock-setup, pkgsel, base-installer, apt-setup, grub-installer, finish-install,
# hw-detect, di-utils) plus tasksel/keyboard-configuration from the main archive.
# No directive here is guessed.
#
# Validated with: debconf-set-selections < preseed.cfg (see debian/README)
# ---------------------------------------------------------------------------
# Installation source
# ---------------------------------------------------------------------------
# ks.cfg:1-2 url --mirrorlist=https://mirrors.fedoraproject.org/...fedora-44
# Debian has no metalink; the canonical archive is the equivalent. Protocol,
# host and directory are preseeded individually so the mirror question is never
# asked and no network round-trip to the mirror list happens.
d-i mirror/country string DE
d-i mirror/protocol select http
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i mirror/suite string trixie
d-i mirror/codename string trixie
# ---------------------------------------------------------------------------
# Language, keyboard, timezone
# ---------------------------------------------------------------------------
# ks.cfg:5 lang de_DE.UTF-8
# language + country are set alongside locale so localechooser never asks: the
# shortlist question is skipped when the locale is already preseeded, and the
# two extra keys make the country/language selection deterministic too.
d-i debian-installer/language string de
d-i debian-installer/country string DE
d-i debian-installer/locale string de_DE.UTF-8
# ks.cfg:5 asks for German only; do not pull in a second locale.
d-i localechooser/supported-locales multiselect de_DE.UTF-8
# ks.cfg:6 keyboard de
# On trixie there is no "debian-installer/keymap" template any more - it survives
# only as an alias handled by env-preseed, which maps "keymap" onto
# keyboard-configuration/xkb-keymap. The real question is the one below, and
# layoutcode is set as well because that is what ends up in
# /etc/default/keyboard as XKBLAYOUT.
d-i keyboard-configuration/xkb-keymap select de
d-i keyboard-configuration/layoutcode string de
d-i keyboard-configuration/modelcode string pc105
d-i keyboard-configuration/variantcode string
# ks.cfg:9 timezone Europe/Berlin
d-i time/zone string Europe/Berlin
# Fedora's installer sets the hardware clock to UTC by default and so does d-i;
# stated explicitly rather than relied on.
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string deb.debian.org
# ---------------------------------------------------------------------------
# Accounts - root
# ---------------------------------------------------------------------------
# ks.cfg:12 rootpw <sha512 hash> --iscrypted
# Same hash, byte for byte. Type is "password" and the value is the crypt(3)
# string, which is exactly what d-i's user-setup-apply feeds to usermod
# --password, so no re-hashing happens anywhere.
d-i passwd/root-password-crypted password $6$3EpVOhxlL/EVU/8f$Z.M5x/x5OdzBFW2C0IoNo5KCsLURBJZnp1BgcMWFz8gsjEPSgAlBKEs7CgZnRAGjbrEzgvUCEydmjtZYvUraJ/
# ks.cfg sets a root password, which on Fedora implies root may log in. d-i
# defaults to locking root when a non-root user exists; say so explicitly.
d-i passwd/root-login boolean true
# ---------------------------------------------------------------------------
# Accounts - users
# ---------------------------------------------------------------------------
# ks.cfg:15 user --name=VDI-ADMIN --password <same hash> --iscrypted --groups=wheel
#
# GAP 1 (important). This CANNOT be expressed as a preseed user.
# user-setup-udeb validates the username with
# LC_ALL=C expr "$USER" : '[a-z][-a-z0-9_]*$'
# (read out of user-setup-udeb 1.107, ./usr/bin/user-setup-ask, state 6).
# "VDI-ADMIN" is uppercase, so it fails validation, and on failure the state
# machine loops back and asks the question again interactively - which would
# hang an unattended install. So the built-in user creation is disabled here and
# BOTH users are created in preseed/late_command instead (see vdi-post.sh
# below), using useradd, which does accept it. Verified on Debian 13:
# useradd -m -G sudo -c 'VDI-00000' VDI-ADMIN -> rc=0
# id VDI-ADMIN -> uid=1000(VDI-ADMIN) groups=...,27(sudo)
# Fedora's "wheel" group is Debian's "sudo" group.
d-i passwd/make-user boolean false
# The kickstart's second user (ks.cfg:85, generated in %pre) is vdi<NNNNN>.
# That name would pass user-setup's validation, but the password is derived from
# the inventory number and the number is only known at run time, so both users
# are created together in late_command for consistency.
d-i passwd/username string vdi00000
d-i passwd/user-fullname string VDI-00000
# ---------------------------------------------------------------------------
# Network
# ---------------------------------------------------------------------------
# ks.cfg:84 network --bootproto=dhcp --hostname=$HOSTNAME --activate
# The hostname is not a constant: it is EXTVDIL<NNNNN> and is derived from the
# operator's answer in preseed/early_command. The value below is only the
# placeholder that is replaced there; "netcfg/hostname" is the documented
# "for internal use; can be preseeded" question that overrides whatever DHCP
# supplies, which is what --hostname does on Fedora.
d-i netcfg/enable boolean true
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string EXTVDIL00000
d-i netcfg/hostname string EXTVDIL00000
# The kickstart does not set a domain and the VDI machines are not in one.
d-i netcfg/get_domain string
d-i netcfg/dhcp_timeout string 60
d-i netcfg/use_autoconfig boolean true
# ---------------------------------------------------------------------------
# Disk partitioning
# ---------------------------------------------------------------------------
# ks.cfg:53-56 (generated in %pre)
# ignoredisk --only-use=$DISK_NAME
# zerombr
# clearpart --all --initlabel
# autopart --fstype=ext4
#
# Mapping:
# ignoredisk --only-use -> partman-auto/disk (restricts the automatic
# partitioner to exactly one disk)
# zerombr + --initlabel -> partman-partitioning/default_label gpt
# (relabels the disk, discarding the old table)
# clearpart --all -> partman-auto/method regular, which builds a fresh
# table from a recipe instead of reusing anything
# autopart --fstype -> partman/default_filesystem ext4
#
# GAP 2 - WHEN the disk is detected, and why it is not preseed/early_command.
# The kickstart detects the disk in %pre, before anaconda partitions. In d-i the
# equivalent-looking hook, preseed/early_command, runs from
# env-preseed's S33preseed_early_command, which is before partman has probed the
# disks - Debian's own example preseed says so explicitly ("disks ... may not be
# visible when preseed/early_command runs") and names the correct hook:
# d-i partman/early_command \
# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# partman-base runs that hook from ./lib/partman/init.d/01early_command, i.e.
# inside partman, with the disk list populated. So the detection lives in
# partman/early_command below.
#
# GAP 3 - the kickstart's two disk tools do not exist in d-i at all.
# `lsblk -d -o rm` and `openssl passwd -6` are both absent from every trixie
# udeb (checked by unpacking them all; d-i has no lsblk, no openssl, no
# python3, no chvt, no passwd binary). The detection below therefore reads
# /sys/block/*/removable and uses udevadm (present, from udev-udeb) for the USB
# test, and nothing is hashed in d-i - the inventory password is set with
# chpasswd in the installed system, which hashes it there.
#
# partman-auto/disk is deliberately NOT set statically: if detection ever fails
# the installer must fall back to the interactive partitioner rather than wipe a
# disk that merely matched a hard-coded default. Detection failure is therefore
# safe-by-construction: nothing is partitioned until the operator confirms.
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string ext4
d-i partman-partitioning/default_label string gpt
d-i partman/alignment select optimal
# Wipe any pre-existing LVM/MD metadata, the way zerombr/clearpart --all do.
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
# No "are you sure?" / "write changes?" dialogs - the kickstart is unattended.
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# Detects the single internal disk, skipping USB and removable devices, then
# hands it to partman. Runs inside partman, after the disks are visible.
# This is the replacement for ks.cfg:18-60.
#
# The kickstart only ever looked at /dev/nvme[0-9]n[0-9] (so its own comment
# about "SATA, NVMe, eMMC" was never true). This scans every block device,
# prefers NVMe as the kickstart intended, and accepts SATA/eMMC/virtio as well.
d-i partman/early_command string \
disk=""; \
for d in /sys/block/*; do \
n=$(basename "$d"); \
case "$n" in loop*|ram*|zram*|sr*|dm-*|md*|fd*) continue ;; esac; \
[ -b "/dev/$n" ] || continue; \
[ "$(cat "$d/removable" 2>/dev/null || echo 1)" = 0 ] || continue; \
if udevadm info -q property -n "/dev/$n" 2>/dev/null | grep -q "^ID_BUS=usb"; then continue; fi; \
case "$n" in nvme*) disk="/dev/$n"; break ;; *) [ -n "$disk" ] || disk="/dev/$n" ;; esac; \
done; \
if [ -n "$disk" ]; then \
debconf-set partman-auto/disk "$disk"; \
debconf-set grub-installer/bootdev "$disk"; \
echo "VDI: internal disk $disk" >> /var/log/vdi-preseed.log; \
else \
echo "VDI: no internal disk found - falling back to the interactive partitioner" >> /var/log/vdi-preseed.log; \
fi
# ---------------------------------------------------------------------------
# Inventory number (ks.cfg:18-93, the whole %pre section)
# ---------------------------------------------------------------------------
# The kickstart writes its results into /tmp/ks_dynamic.cfg and %includes it.
# d-i has no %include; the same effect is achieved by writing the derived values
# straight into debconf with debconf-set (from di-utils), which is the sanctioned
# idiom - Debian's example preseed uses it for partman-auto/disk.
#
# GAP 4 - the prompt itself. The kickstart switches to TTY3 with `chvt 3` and
# reads from /dev/tty3. d-i ships neither chvt nor openvt (confirmed absent from
# every udeb), and preseed_command runs the hook through `log-output`, which
# sends stdout to the log rather than to the screen. So the prompt is written to
# and read from /dev/console directly, which is the console the operator is
# actually looking at.
#
# Two safety valves the kickstart does not have, because an unattended run must
# not hang forever on a `read` that nobody answers:
# * vdi.inventory=NNNNN on the kernel command line skips the prompt entirely;
# * otherwise the prompt waits 120 s and then uses the kickstart's default,
# 00000.
# Both are documented in debian/README.
d-i preseed/early_command string \
inv=""; \
for a in $(cat /proc/cmdline); do case "$a" in vdi.inventory=*) inv="${a#vdi.inventory=}" ;; esac; done; \
if [ -z "$inv" ] && [ -c /dev/console ]; then \
printf "\n\nEnter the 5-digit inventory number for this device (default 00000): " > /dev/console; \
IFS= read -r -t 120 inv < /dev/console || true; \
fi; \
[ -n "$inv" ] || inv=00000; \
inv=$(printf "%s" "$inv" | tr -cd "0-9" | cut -c1-5); \
[ -n "$inv" ] || inv=00000; \
while [ ${#inv} -lt 5 ]; do inv="0${inv}"; done; \
printf "%s" "$inv" > /tmp/vdi.inventory; \
debconf-set netcfg/hostname "EXTVDIL${inv}"; \
debconf-set netcfg/get_hostname "EXTVDIL${inv}"; \
debconf-set passwd/username "vdi${inv}"; \
debconf-set passwd/user-fullname "VDI-${inv}"; \
echo "VDI: inventory=${inv}" >> /var/log/vdi-preseed.log
#
# ks.cfg:73 INVENTORY_NUM=$(printf "%05d" ${INVENTORY_NUM:0:5})
# Reproduced, but with a zero-padding loop instead of printf: `printf "%05d"`
# treats the value as octal, so the kickstart's own line fails on an inventory
# number containing an 8 or 9 (e.g. 00019). The loop gives the same result and
# cannot fail.
#
# Derived values, all from ks.cfg:77-80:
# hostname EXTVDIL<NNNNN> -> netcfg/hostname above
# username vdi<NNNNN> -> passwd/username above
# full name VDI-<NNNNN> -> passwd/user-fullname above
# password pwVDI#<NNNNN> -> set with chpasswd in late_command
# (d-i has no openssl, see GAP 3)
# ---------------------------------------------------------------------------
# Boot loader
# ---------------------------------------------------------------------------
# ks.cfg:96 bootloader --location=mbr
# The device is set from the detected disk in partman/early_command above, which
# is the same disk the partitioning is restricted to. "default" would also work
# but naming the disk is closer to --location=mbr and cannot pick the wrong one.
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
# ---------------------------------------------------------------------------
# Package selection
# ---------------------------------------------------------------------------
# ks.cfg:99-105
# @^kde-desktop-environment
# createrepo_c
# python3-pip
# firefox
# git
#
# @^kde-desktop-environment -> the "kde-desktop" task (verified in
# tasksel-data 3.81: Task: kde-desktop, Parent: desktop). "standard" is the
# Debian equivalent of the base group anaconda always installs.
# firefox -> firefox-esr (trixie has no package called
# "firefox"; verified in the trixie Packages index)
# createrepo_c -> apt-utils, which is what provides apt-ftparchive,
# the tool that builds a flat apt repository. There is no createrepo on
# Debian and no createrepo_c either.
# python3-pip -> DROPPED. ks.cfg:143 installs pip only in order to run
# `pip install tqdm`, and that one use is served by python3-tqdm from apt (GAP 5).
# Debian 13 marks /usr/lib/python3/dist-packages EXTERNALLY-MANAGED (PEP 668), so
# any user who tries `pip install <anything>` after install gets
# "error: externally-managed-environment" and has to reach for
# --break-system-packages. Measured on trixie, not assumed: `pip3 install
# requests` is blocked AND so is `pip3 install --user six`. So installing
# python3-pip would not make pip usable - it only changes the error from
# "command not found" to "externally-managed-environment". It adds no capability
# that this image would otherwise have. This is a deliberate difference from the
# Fedora kickstart. The supported route is a venv, which is why python3-venv is
# installed below instead.
tasksel tasksel/first multiselect standard, kde-desktop
# Package list notes, one per entry that is not a straight rename:
# python3 - update_local_repo.py is python3 and the cron job runs it.
# A bare trixie install has no python3, and without it the
# cron job fails every 10 minutes with only a log line.
# apt-utils - provides apt-ftparchive, which update_local_repo.py calls
# to build the local Citrix repo (the createrepo_c slot).
# python3-tqdm - the tqdm dependency, from apt instead of pip (GAP 5).
# python3-venv - the replacement for the dropped python3-pip: a venv is the
# only way to install a third-party Python package on trixie.
# `python3 -m venv` needs this package to create a working
# pip inside the venv; without it a user has no route at all.
# Verified on trixie: python3 -m venv gives pip 25.1.1 and
# `venv/bin/pip install six` succeeds (EXTERNALLY-MANAGED does
# not apply inside a venv). It pulls python3-pip-whl, which is
# pip bundled as a wheel for venv use - that is NOT python3-pip
# and does not put a system pip3 on PATH.
# wget - the teamviewer key download in the post-install script
# uses wget (present in trixie as 1.25.0-2).
# sudo - needed for the "sudo" group. The kde-desktop task does not
# pull sudo in, and `useradd -G sudo` would otherwise
# succeed with a warning and leave VDI-ADMIN unable to sudo.
# cron - the kickstart appends to /etc/crontab and restarts crond;
# Debian does not install cron by default.
# packagekit-tools - provides pkcon, used by /root/auto_update.sh.
# iputils-ping - the @reboot cron line waits on `ping google.com`.
d-i pkgsel/include string git python3 python3-tqdm python3-venv firefox-esr apt-utils cron sudo ca-certificates wget iputils-ping packagekit-tools systemd
d-i pkgsel/run_tasksel boolean true
# ks.cfg does not upgrade the system during install, and does not enable
# automatic security updates (it runs its own pkcon-based updater instead).
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
d-i pkgsel/updatedb boolean false
d-i base-installer/install-recommends boolean true
#
# GAP 5 - tqdm. ks.cfg:143 does `pip install tqdm`, because Fedora ships pip and
# lets it write into /usr. Debian 13 does not: pip3 is not installed by default,
# and /usr/lib/python3.13/EXTERNALLY-MANAGED is present (PEP 668), so a
# system-wide pip install is refused even after installing pip. The Debian way,
# and what this file does, is the distribution package python3-tqdm
# (4.67.1-5 on trixie). `pip install --break-system-packages` is deliberately
# not used, and because the only thing the kickstart wanted pip for was tqdm,
# python3-pip itself is not installed either - see the package-selection note
# above. Measured on trixie: `pip3 install X` and `pip3 install --user X` are both
# refused with externally-managed-environment, so pip would have been dead weight.
# python3-venv is installed in its place, which is the supported route.
#
# GAP 6 - `pkcon` is used by the auto-update script below. On Fedora it comes
# with the desktop; on Debian it is in packagekit-tools, which is therefore in
# the list above. iputils-ping is there because the kickstart's @reboot cron
# line waits on `ping google.com` and Debian does not install ping by default.
# ---------------------------------------------------------------------------
# Remainder of the installer, made non-interactive
# ---------------------------------------------------------------------------
# There is no kickstart equivalent for these; they exist so that nothing else
# stops and waits for a human.
d-i hw-detect/load_firmware boolean false
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/enable-source-repositories boolean false
d-i finish-install/keep-consoles boolean false
d-i cdrom-detect/eject boolean false
# ---------------------------------------------------------------------------
# %post (ks.cfg:108-221)
# ---------------------------------------------------------------------------
# The kickstart's %post is a multi-line bash script with `set -euxo pipefail`.
# A preseed value is a single line (continuations are joined with spaces), so a
# multi-line script cannot be written inline. Instead late_command writes the
# script to /root/vdi-post.sh in the installed system, line by line, and then
# runs it with bash. That keeps it a real script - which is what makes
# `set -euo pipefail` possible at all, since preseed_command itself uses
# /bin/sh (dash, no pipefail) - and it stays readable here.
#
# The script is reproduced verbatim below as a comment so it can be reviewed
# against ks.cfg without decoding anything. The printf arguments that follow it
# are exactly these lines, in this order.
#
# ---8<--- /root/vdi-post.sh ---8<---
# #!/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"
# ---8<--- end /root/vdi-post.sh ---8<---
#
# Differences from the kickstart's %post, all forced by Debian:
#
# * Firefox policies path (ks.cfg:113-136) is UNCHANGED: on trixie
# /etc/firefox/policies/policies.json is the path firefox-esr actually reads,
# with MOZ_SYSTEM_POLICIES compiled in. It is written from late_command
# straight into /target (mode 644, root:root) rather than from the script,
# because no chroot is needed to create a file.
# * pip install tqdm (ks.cfg:143) -> python3-tqdm from the package list; see
# GAP 5.
# * dnf install ICAClient / ctxusb (ks.cfg:147-149) -> apt-get install icaclient
# ctxusb, after update_local_repo.py has built the local flat repo at
# /var/local/citrix-repo. The Fedora RPM names differ in case from the Debian
# package names.
# * dnf install teamviewer from the yum repo (ks.cfg:151-167) -> apt-get from
# 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
# next run, so the Debian path logs the failure and continues. This is a
# deliberate behavioural difference, not an oversight.
# * `openssl passwd -6` in %pre (ks.cfg:83) produced a SHA-512 crypt hash for
# the vdi<NNNNN> password. d-i has no openssl, so that password is set in
# the installed system with chpasswd, which uses whatever crypt scheme the
# target's PAM default is - yescrypt on trixie, not SHA-512. The password
# VALUE is identical; only the stored hash format differs. The root and
# VDI-ADMIN hashes are still the kickstart's exact SHA-512 strings, passed
# through unchanged, so those two accounts match the Fedora machines exactly.
# * `systemctl start disable-sleep.service` (ks.cfg:217) is dropped and only
# `systemctl enable` is kept: late_command runs inside a chroot where systemd
# is not the init process, so `start` cannot work. The unit is enabled and is
# WantedBy=multi-user.target, so it starts on first boot - same end state.
# For the same reason `systemctl daemon-reload` is not called; nothing needs
# it before boot.
# * `systemctl restart crond` (ks.cfg:190) -> `systemctl enable cron`. The
# service is called cron on Debian, and it is not running in the chroot.
# * The commented-out hourly auto_update cron line (ks.cfg:186) is not carried
# over - it is dead in the kickstart too.
#
# late_command:
# 1. writes /etc/firefox/policies/policies.json (ks.cfg:113-135)
# 2. writes /etc/apt/sources.list.d/teamviewer.list (ks.cfg:152-162)
# 3. writes /root/vdi-post.sh from the lines above and runs it under bash
d-i preseed/late_command string \
inv=$(cat /tmp/vdi.inventory 2>/dev/null || echo 00000); \
echo "VDI: late_command, inventory=${inv}" >> /var/log/vdi-preseed.log; \
mkdir -p /target/etc/firefox/policies; \
printf "%s\n" "{" " \"policies\": {" " \"ManagedBookmarks\":" " [" " {" " \"toplevel_name\": \"Reyher\"" " }," " {" " \"name\": \"Arbeit\"," " \"url\": \"https://workspace.reyher.de/\"" " }" " ]" " }" "}" > /target/etc/firefox/policies/policies.json; \
chmod 644 /target/etc/firefox/policies/policies.json; \
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' '# 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"
# ===========================================================================
# GAPS - what the preseed mechanism cannot reproduce, consolidated
# ===========================================================================
# 1. `user --name=VDI-ADMIN` - impossible. user-setup rejects uppercase names
# and re-prompts (hangs an unattended install). Done in late_command with
# useradd instead. wheel -> sudo.
# 2. Disk detection cannot run in preseed/early_command - disks are not visible
# yet. Done in partman/early_command, the hook Debian documents for exactly
# this.
# 3. `lsblk` and `openssl` do not exist in d-i. Detection uses
# /sys/block/*/removable + udevadm; hashing is done in the installed system
# by chpasswd.
# 4. `chvt 3` / /dev/tty3 prompt - no chvt or openvt in d-i, and preseed_command
# redirects stdout to the log. Prompt goes to /dev/console, with a kernel
# cmdline override and a timeout so it cannot hang forever.
# 5. `pip install tqdm` - PEP 668 on Debian 13. Uses python3-tqdm.
# 6. `createrepo_c` - no Debian equivalent; apt-utils (apt-ftparchive) is
# installed instead for the local Citrix repo.
# 7. `systemctl start` inside %post - no systemd in the chroot. The unit is
# enabled instead and starts on first boot.
# 8. `printf "%05d"` on the inventory number - the kickstart's own line breaks
# on a number containing 8 or 9 (octal). Replaced with a padding loop.
# 9. Password hash format for vdi<NNNNN> - the kickstart's `openssl passwd -6`
# made SHA-512; chpasswd on trixie makes yescrypt. Same password, different
# stored hash. Root and VDI-ADMIN keep the kickstart's exact SHA-512 hashes.
# 10. The kickstart's own `printf "%05d"` bug (see 8) is fixed here, so an
# inventory number such as 00019 installs correctly on Debian and would
# not have on Fedora. Flagged rather than silently matched.
# 11. `git clone` of the internal repo is FAIL-SOFT here, where the kickstart
# (which runs under `set -euxo pipefail`) would abort the whole %post. The
# reason: on Fedora the repo host was reachable during install; on a Debian
# VDI the install may legitimately finish before the corporate network is up,
# and aborting would leave a half-configured machine. The clone is logged and
# the 10-minute cron job retries it. THIS IS A DELIBERATE BEHAVIOURAL
# DIFFERENCE, not an oversight - if the repo must be present before first
# boot, this line needs to fail hard instead and the installer needs to wait
# for network.