ISO: add --offline bundle so the kiosk installs with no internet

`iso/build-iso.sh --offline` (and the workflow's new `offline` box, on by
default) adds ~420 MB to the ISO and copies it to /opt/kiosk-offline:

- apt/: local repository with every package install.sh's provisioning
  and the CUPS addon install ask for, NodeSource's nodejs, and all
  dependencies a fresh server install doesn't already have. Resolved
  against the source ISO's own package manifest via a synthesized dpkg
  status (iso/offline/fake-dpkg-status.py), so apt downloads only what's
  missing and makes the same virtual/alternative choices as the target.
- npm/: prebuilt kiosk-app (Electron 42, binary included - it no longer
  downloads at npm install time) and Web UI node_modules.

On first boot, kiosk-firstboot installs online as before when there's
internet; with none it waits KIOSK_OFFLINE_WAIT (90s), then runs
`kiosk-offline-apt on` (apt.conf.d drop-in: bundle is the ONLY source)
and turns it off again afterwards. install.sh notices offline mode via
offline_mode_active (lib/config.sh) and installs nodejs from the bundle
and unpacks prebuilt node_modules instead of npm install.

Package lists moved into PROVISION_APT_PACKAGES /
PROVISION_INTEL_APT_PACKAGES / CUPS_APT_PACKAGES so the bundler reads
the same lists install.sh installs from.

Tested: built against the 26.04.1 ISO, then in a network-less chroot of
the ISO's own server filesystem installed every package set, ran
provision_create_kiosk_user/install_nodejs/install_app and
webui_install_app_files in offline mode (Electron runs, no missing
libraries, chrome-sandbox setuid), and ran kiosk-firstboot through the
offline switch with a stub install.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cjz8a58eB5P9sUweqd3NHm
This commit is contained in:
Claude
2026-10-03 04:34:32 +00:00
parent 125622cd74
commit a170dc6228
11 changed files with 586 additions and 38 deletions
+30
View File
@@ -41,6 +41,16 @@
# other addon's own scripts.
: "${WEBUI_HELPER_PATH:=$BIN_DIR/kiosk-webui-helper}"
# Offline install bundle - only present on systems installed from an ISO
# built with `iso/build-iso.sh --offline`: a local apt repository (every
# package provisioning and the CUPS addon install) plus prebuilt
# node_modules for the kiosk app and Web UI. Offline mode is switched on
# by /usr/local/sbin/kiosk-offline-apt (which writes $KIOSK_OFFLINE_APT_CONF
# pointing apt at that repository only) - the first-boot service does that
# automatically when there's no internet; by hand: `sudo kiosk-offline-apt on`.
: "${KIOSK_OFFLINE_DIR:=/opt/kiosk-offline}"
: "${KIOSK_OFFLINE_APT_CONF:=/etc/apt/apt.conf.d/90-kiosk-offline}"
# The admin account actually running this tool (as opposed to $KIOSK_USER,
# the kiosk's own restricted account) - used where an addon needs to grant
# *this* user a group membership (e.g. lpadmin for CUPS).
@@ -74,6 +84,26 @@ AUTHELIA_URL=""
AUTHELIA_USERNAME=""
AUTHELIA_ENCRYPTED_PASSWORD=""
offline_mode_active() {
[[ -f "$KIOSK_OFFLINE_APT_CONF" && -d "$KIOSK_OFFLINE_DIR/apt" ]]
}
# offline_install_node_modules NAME DEST_DIR
# Unpacks the bundle's prebuilt node_modules for NAME (kiosk-app, webui)
# into DEST_DIR as $KIOSK_USER, in place of `npm install` - which can't
# reach the npm registry (or Electron's GitHub download) offline.
offline_install_node_modules() {
local name="$1" dest="$2"
local tarball="$KIOSK_OFFLINE_DIR/npm/${name}-node_modules.tar.gz"
if [[ ! -f "$tarball" ]]; then
log_error "Offline bundle has no prebuilt modules for $name ($tarball)"
return 1
fi
echo "Offline mode: unpacking prebuilt $name modules from $KIOSK_OFFLINE_DIR..."
sudo -u "$KIOSK_USER" rm -rf "$dest/node_modules"
sudo -u "$KIOSK_USER" tar -xzf "$tarball" -C "$dest"
}
kiosk_user_exists() {
id "$KIOSK_USER" &>/dev/null
}
+41 -24
View File
@@ -54,23 +54,31 @@ provision_install_file() {
sudo install -D -m "$mode" "$PROVISION_FILES/$src_rel" "$dest"
}
# Package lists live in variables, not inline, so iso/offline/build-bundle.sh
# (the offline install ISO) can read the exact same lists to bundle - add a
# package here and the offline bundle picks it up on its next build.
PROVISION_APT_PACKAGES=(
xorg openbox lightdm unclutter screen curl git build-essential
ca-certificates gnupg lsb-release jq ufw x11-xserver-utils xinput
vainfo mesa-utils libgl1-mesa-dri libglx-mesa0 mesa-vulkan-drivers
libva2 libva-drm2 libva-x11-2 mesa-va-drivers
libegl-mesa0 libegl1-mesa-dev libgles2-mesa-dev
pipewire pipewire-pulse pipewire-alsa wireplumber pipewire-audio-client-libraries alsa-utils libnotify-bin
gstreamer1.0-pipewire libspa-0.2-bluetooth
systemd-timesyncd acpid xbindkeys xdotool python3-evdev unzip
net-tools ncdu evtest
)
PROVISION_INTEL_APT_PACKAGES=(
intel-gpu-tools xserver-xorg-video-intel i965-va-driver intel-media-va-driver
)
provision_install_packages() {
echo "[1/10] Installing packages..."
sudo apt update
sudo apt install -y \
xorg openbox lightdm unclutter screen curl git build-essential \
ca-certificates gnupg lsb-release jq ufw x11-xserver-utils xinput \
vainfo mesa-utils libgl1-mesa-dri libglx-mesa0 mesa-vulkan-drivers \
libva2 libva-drm2 libva-x11-2 mesa-va-drivers \
libegl-mesa0 libegl1-mesa-dev libgles2-mesa-dev \
pipewire pipewire-pulse pipewire-alsa wireplumber pipewire-audio-client-libraries alsa-utils libnotify-bin \
gstreamer1.0-pipewire libspa-0.2-bluetooth \
systemd-timesyncd acpid xbindkeys xdotool python3-evdev unzip \
net-tools ncdu evtest
sudo apt install -y "${PROVISION_APT_PACKAGES[@]}"
if lspci | grep -i "VGA.*Intel" >/dev/null 2>&1; then
sudo apt install -y intel-gpu-tools xserver-xorg-video-intel \
i965-va-driver intel-media-va-driver
sudo apt install -y "${PROVISION_INTEL_APT_PACKAGES[@]}"
provision_install_file "etc/X11/xorg.conf.d/20-intel.conf" /etc/X11/xorg.conf.d/20-intel.conf
fi
@@ -101,8 +109,13 @@ provision_create_kiosk_user() {
provision_install_nodejs() {
echo "[3/10] Installing Node.js..."
if ! command -v node &>/dev/null; then
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
if offline_mode_active; then
# The bundle carries NodeSource's own nodejs package.
sudo apt install -y nodejs
else
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
fi
fi
echo "Node.js: $(node -v)"
}
@@ -113,16 +126,20 @@ provision_install_app() {
sudo chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_DIR"/*.js "$KIOSK_DIR"/*.html "$KIOSK_DIR/package.json" "$KIOSK_DIR/start.sh"
sudo chmod +x "$KIOSK_DIR/start.sh"
echo "Installing npm dependencies (Electron ~120MB - may take several minutes)..."
sudo -u "$KIOSK_USER" bash -lc "
npm config set fetch-timeout 600000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 30000
npm config set fetch-retry-maxtimeout 300000
"
if ! sudo -u "$KIOSK_USER" bash -lc "cd '$KIOSK_DIR' && npm install --unsafe-perm"; then
log_error "npm install failed"
return 1
if offline_mode_active; then
offline_install_node_modules kiosk-app "$KIOSK_DIR"
else
echo "Installing npm dependencies (Electron ~120MB - may take several minutes)..."
sudo -u "$KIOSK_USER" bash -lc "
npm config set fetch-timeout 600000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 30000
npm config set fetch-retry-maxtimeout 300000
"
if ! sudo -u "$KIOSK_USER" bash -lc "cd '$KIOSK_DIR' && npm install --unsafe-perm"; then
log_error "npm install failed"
return 1
fi
fi
electron_install_binary