Files
daynivo-kiosk-os/image/build.sh
T
rothmanandClaude Opus 5.5 eb0242c182
CI / test-bookworm (push) Successful in 29s
CI / test-latest (push) Successful in 31s
Rename every remaining voxip name to daynivo, with a one-time migration
Services (daynivo-kiosk-*, daynivo-network-guard, daynivo-boot-import),
programs in /usr/lib/daynivo-kiosk, folders /etc, /var/lib, /var/log and
/var/cache daynivo-kiosk*, the system user daynivo, DAYNIVO_* settings,
the plymouth theme, network profiles daynivo-eth0/wlan0, the image stage
and its first user daynivoadmin.

install.sh moves a kiosk installed up to 1.2.x over once: old services
stopped and removed, folders moved (configuration, password, browser
profile, logs) with symlinks under the old names, the voxip user renamed
with the same uid, network profiles renamed unless a change awaits
confirmation, and old leftovers removed. Tested by upgrading a configured
1.2.0 installation in a container, and running the install a second time.

Old names keep working where people type or place them: voxip-config.json,
voxip-authorized_keys, voxip-network-reset, voxip-kiosk-ctl, and
VOXIP_DEFAULT_URL / VOXIP_DEVICE_NAME for image builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:58:03 +01:00

125 lines
4.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
#
# Build a flashable Daynivo Kiosk OS image (.img.xz) with pi-gen.
#
# ./image/build.sh # build in Docker (recommended)
# sudo ./image/build.sh --native # build directly on a Debian/Ubuntu host
#
# Environment (all optional):
# PI_GEN_REF pi-gen tag/branch (32-bit armhf). Default: pinned Bookworm release.
# RELEASE bookworm | trixie (must match PI_GEN_REF). Default: bookworm.
# DAYNIVO_DEFAULT_URL kiosk URL baked into the default config.
# DAYNIVO_DEVICE_NAME default device name.
# TARGET_HOSTNAME default hostname (the admin UI is at http://<hostname>.local:8080).
# ALLOW_DIRTY=1 build from the working tree instead of the committed HEAD.
#
# Output: image/deploy/<date>-daynivo-kiosk-os-<version>.img.xz (+ .sha256)
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WORK="${WORK_DIR:-$ROOT/image/work}"
OUT="$ROOT/image/deploy"
PI_GEN_REPO="${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen.git}"
PI_GEN_REF="${PI_GEN_REF:-2024-11-19-raspios-bookworm-armhf}"
RELEASE="${RELEASE:-bookworm}"
# VOXIP_* are the names from before the rename and still work.
DAYNIVO_DEFAULT_URL="${DAYNIVO_DEFAULT_URL:-${VOXIP_DEFAULT_URL:-https://schermen-ijsselflat.voxip.nl}}"
DAYNIVO_DEVICE_NAME="${DAYNIVO_DEVICE_NAME:-${VOXIP_DEVICE_NAME:-Daynivo Kiosk}}"
TARGET_HOSTNAME="${TARGET_HOSTNAME:-kiosk}"
NATIVE=0
[[ ${1:-} == "--native" ]] && NATIVE=1
[[ ${1:-} == "-h" || ${1:-} == "--help" ]] && { sed -n '3,18p' "$0" | sed 's/^# \{0,1\}//'; exit 0; }
VERSION="$(tr -d '[:space:]' < "$ROOT/VERSION")"
command -v git >/dev/null || { echo "git is vereist" >&2; exit 1; }
if [[ $NATIVE -eq 0 ]]; then
command -v docker >/dev/null || { echo "Docker is vereist (of gebruik --native op Debian/Ubuntu)" >&2; exit 1; }
else
[[ $EUID -eq 0 ]] || { echo "--native moet met sudo" >&2; exit 1; }
fi
echo "==> pi-gen $PI_GEN_REF ophalen"
mkdir -p "$WORK" "$OUT"
rm -rf "$WORK/pi-gen"
git clone --quiet --depth 1 --branch "$PI_GEN_REF" "$PI_GEN_REPO" "$WORK/pi-gen"
PI_GEN_COMMIT="$(git -C "$WORK/pi-gen" rev-parse HEAD)"
PIGEN="$WORK/pi-gen"
# Do not export the plain Lite image from stage2; ours is exported after stage-daynivo.
touch "$PIGEN/stage2/SKIP_IMAGES"
rm -f "$PIGEN/stage2/EXPORT_NOOBS"
echo "==> Daynivo-stage voorbereiden"
cp -a "$ROOT/image/stage-daynivo" "$PIGEN/stage-daynivo"
PAYLOAD="$PIGEN/stage-daynivo/00-daynivo/files/daynivo-kiosk"
mkdir -p "$PAYLOAD"
if [[ ${ALLOW_DIRTY:-0} == 1 ]] || ! git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1; then
echo " (werkmap wordt gebruikt, niet de laatste commit)"
tar -C "$ROOT" --exclude=./image/work --exclude=./image/deploy --exclude=./.git --exclude=./.venv \
--exclude='__pycache__' --exclude=.pytest_cache -cf - . | tar -C "$PAYLOAD" -xf -
SOURCE_REV="werkmap"
else
if [[ -n "$(git -C "$ROOT" status --porcelain)" ]]; then
echo " Let op: niet-gecommitte wijzigingen worden NIET meegenomen (ALLOW_DIRTY=1 om dat wel te doen)."
fi
git -C "$ROOT" archive HEAD | tar -C "$PAYLOAD" -xf -
SOURCE_REV="$(git -C "$ROOT" rev-parse HEAD)"
fi
BUILD_DATE="$(date -u +%Y-%m-%d)"
cat > "$PIGEN/stage-daynivo/00-daynivo/files/build.env" <<EOF
DAYNIVO_DEFAULT_URL=$(printf %q "$DAYNIVO_DEFAULT_URL")
DAYNIVO_DEVICE_NAME=$(printf %q "$DAYNIVO_DEVICE_NAME")
EOF
cat > "$PAYLOAD/BUILD-INFO" <<EOF
daynivo_kiosk_os=$VERSION
source_revision=$SOURCE_REV
pi_gen_ref=$PI_GEN_REF
pi_gen_commit=$PI_GEN_COMMIT
release=$RELEASE
build_date=$BUILD_DATE
EOF
# The image has no usable default password: the first user is locked and is
# only unlocked by credentials from Raspberry Pi Imager (or SSH keys placed
# on the boot partition, see README).
FIRST_USER_PASS="$(openssl rand -base64 33 | tr -d '\n/+=')"
cat > "$PIGEN/config" <<EOF
IMG_NAME=daynivo-kiosk-os-$VERSION
IMG_DATE=$BUILD_DATE
RELEASE=$RELEASE
DEPLOY_COMPRESSION=xz
COMPRESSION_LEVEL=6
LOCALE_DEFAULT=nl_NL.UTF-8
KEYBOARD_KEYMAP=us
KEYBOARD_LAYOUT="English (US)"
TIMEZONE_DEFAULT=Europe/Amsterdam
WPA_COUNTRY=NL
TARGET_HOSTNAME=$TARGET_HOSTNAME
FIRST_USER_NAME=daynivoadmin
FIRST_USER_PASS=$FIRST_USER_PASS
DISABLE_FIRST_BOOT_USER_RENAME=1
ENABLE_SSH=0
STAGE_LIST="stage0 stage1 stage2 stage-daynivo"
EOF
echo "==> Image bouwen (dit duurt 30–90 minuten)"
cd "$PIGEN"
if [[ $NATIVE -eq 1 ]]; then
./build.sh
else
CONTINUE=0 PRESERVE_CONTAINER=0 ./build-docker.sh
fi
shopt -s nullglob
images=("$PIGEN"/deploy/*.img.xz)
[[ ${#images[@]} -gt 0 ]] || { echo "Geen image gevonden in $PIGEN/deploy" >&2; exit 1; }
for img in "${images[@]}"; do
cp "$img" "$OUT/"
(cd "$OUT" && sha256sum "$(basename "$img")" > "$(basename "$img").sha256")
echo "==> Klaar: $OUT/$(basename "$img")"
done
cp "$PAYLOAD/BUILD-INFO" "$OUT/BUILD-INFO-$VERSION.txt"