#!/usr/bin/env bash # # Smart Home Door-Panel ISO Builder # Target: builds a Debian 12 (Bookworm) live ISO on a Debian/Ubuntu build machine # # Drives `lb config && lb build` over hosts/door-panel/live-build/ to produce the # door/wardrobe panel described in docs/project-plan.md Phase 18: # - greetd autologin straight into a kiosk Sway session (no greeter UI) # - ONE Chromium kiosk window, default screen identity's dashboard.html (weather + # what-to-wear, who's home, groceries running low), "Show registration" on demand # - door-panel-agent (Python, systemd) — HA MQTT "Show home/registration" buttons # only; presence/weather/groceries/registration all come from identity's and # pantry-vision's own published APIs, called directly by the browser # - wyoming-satellite + openWakeWord for voice registration ("register me as # ") — opt-in like every other host's mic, but this device's whole point, # so expect it on for a real deployment # # Reuses hosts/thin-client's live-build toolchain and directory-split convention, not # its live-build tree — same relationship hosts/touch-panel, hosts/audio-endpoint, # and hosts/kitchen-display already have to the thin client's. Structurally this is # hosts/kitchen-display's twin: same one-workspace-two-kiosk-destinations shape, # different default content and a mic that's actually expected to be used. # # Run as: sudo ./build-door-panel-iso.sh # # EDIT THE VARIABLES BELOW BEFORE RUNNING. set -euo pipefail # --------------------------------------------------------------------------- # CONFIGURATION — edit these before running # --------------------------------------------------------------------------- DEBIAN_RELEASE="bookworm" KIOSK_USERNAME="kiosk" IMAGE_HOSTNAME="door-panel" DOOR_PANEL_NAME="Door panel" KEYBOARD_LAYOUT="de" ENABLE_INSTALLER="false" # --- Where the door panel talks to ------------------------------------------- MQTT_BROKER_HOST="192.168.1.10" # <-- EDIT: container-host IP running Mosquitto MQTT_BROKER_PORT="1883" MQTT_USERNAME="" MQTT_PASSWORD="" # identity's dashboard/registration pages and API — ENABLE_IDENTITY in # setup-container-host.sh. Placeholders until that's deployed; the image builds and # boots fine without it, the kiosk window just shows a connection error. IDENTITY_WEB_URL="http://192.168.1.10:8098" # <-- EDIT once identity-web is deployed IDENTITY_URL="http://192.168.1.10:8097" # <-- EDIT once identity is deployed # Must match identity/identity.env's own token — no way for this repo to push it # between the two hosts for you. IDENTITY_TOKEN="" # <-- EDIT # pantry-vision — only needed for the dashboard's "Running low" section; the rest of # the dashboard (weather, who's home) works without it. Same placeholder handling. PANTRY_VISION_URL="http://192.168.1.10:8095" # <-- EDIT once pantry-vision is deployed PANTRY_VISION_TOKEN="" # <-- EDIT: must match pantry-vision's own token # --- Voice registration ("register me as ") — this device's whole point, so # --- true is the expected real-deployment value, unlike hosts/kitchen-display's # --- identical flag — but still requires a real mic on this specific unit. ENABLE_VOICE_SATELLITE="true" VOICE_SATELLITE_NAME="Door panel" VOICE_WAKE_WORD="ok_nabu" SSH_AUTHORIZED_KEY="" # --------------------------------------------------------------------------- # Paths # --------------------------------------------------------------------------- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DOOR_PANEL_DIR="$(dirname "$SCRIPT_DIR")" CONFIGS_DIR="${DOOR_PANEL_DIR}/configs" AGENT_DIR="${DOOR_PANEL_DIR}/agent" LIVE_BUILD_DIR="${DOOR_PANEL_DIR}/live-build" INCLUDES="${LIVE_BUILD_DIR}/config/includes.chroot" PACKAGE_LIST="${LIVE_BUILD_DIR}/config/package-lists/door-panel.list.chroot" # --------------------------------------------------------------------------- # Sanity checks # --------------------------------------------------------------------------- if [[ $EUID -ne 0 ]]; then echo "Warning: not running as root. 'lb build' needs root; re-run with: sudo $0" echo " Continuing anyway so you can at least regenerate includes.chroot..." fi if ! command -v lb &> /dev/null; then if [[ $EUID -eq 0 ]]; then echo "--- Installing live-build ---" apt-get update apt-get install -y live-build else echo "live-build is not installed and this script is not running as root." >&2 echo " Install it first: sudo apt-get install live-build" >&2 exit 1 fi else echo "--- live-build already installed, skipping ---" fi if [[ ! -f "$PACKAGE_LIST" ]]; then echo "Missing package list: $PACKAGE_LIST" >&2 exit 1 fi if [[ "$MQTT_BROKER_HOST" == "192.168.1.10" ]]; then echo "Warning: MQTT_BROKER_HOST is still the placeholder IP — edit it before building." fi if [[ -z "$IDENTITY_TOKEN" ]]; then echo "Warning: IDENTITY_TOKEN is empty. The dashboard will load but every call to" echo " identity will fail (401) until this matches the token in" echo " identity/identity.env on the container host." fi if [[ -z "$PANTRY_VISION_TOKEN" ]]; then echo "Warning: PANTRY_VISION_TOKEN is empty. 'Running low' will show as unconfigured" echo " until this matches the token in pantry-vision/pantry-vision.env." fi if [[ "$ENABLE_VOICE_SATELLITE" == "true" ]]; then echo "Note: ENABLE_VOICE_SATELLITE=true — this image expects a real microphone on" echo " the physical unit. Don't flash it to hardware that doesn't have one." fi echo echo "=== Smart Home Door-Panel ISO Builder ===" echo "Debian release : $DEBIAN_RELEASE" echo "Kiosk user : $KIOSK_USERNAME" echo "Image hostname : $IMAGE_HOSTNAME" echo "MQTT broker : ${MQTT_BROKER_HOST}:${MQTT_BROKER_PORT}" echo "identity-web : $IDENTITY_WEB_URL" echo "identity : $IDENTITY_URL" echo "pantry-vision : $PANTRY_VISION_URL" echo "Voice satellite : $ENABLE_VOICE_SATELLITE" echo "Keyboard layout : $KEYBOARD_LAYOUT" echo # --------------------------------------------------------------------------- # 1. Regenerate includes.chroot from configs/ and agent/ # --------------------------------------------------------------------------- echo "--- Regenerating $INCLUDES ---" rm -rf "$INCLUDES" mkdir -p \ "$INCLUDES/etc/greetd" \ "$INCLUDES/etc/door-panel-agent" \ "$INCLUDES/usr/local/bin" \ "$INCLUDES/opt/door-panel-agent" \ "$INCLUDES/home/${KIOSK_USERNAME}/.config/sway" \ "$INCLUDES/home/${KIOSK_USERNAME}/.ssh" subst() { sed -e "s/@KIOSK_USERNAME@/${KIOSK_USERNAME}/g" \ -e "s/@KEYBOARD_LAYOUT@/${KEYBOARD_LAYOUT}/g" "$1" > "$2" } subst "${CONFIGS_DIR}/greetd/config.toml" "$INCLUDES/etc/greetd/config.toml" subst "${CONFIGS_DIR}/sway/config" "$INCLUDES/home/${KIOSK_USERNAME}/.config/sway/config" subst "${AGENT_DIR}/door-panel-agent.service" "$INCLUDES/opt/door-panel-agent/door-panel-agent.service" install -m 0755 "${CONFIGS_DIR}/greetd/kiosk-session" "$INCLUDES/usr/local/bin/kiosk-session" install -m 0755 "${CONFIGS_DIR}/sway/home-kiosk" "$INCLUDES/usr/local/bin/home-kiosk" install -m 0755 "${CONFIGS_DIR}/sway/identity-kiosk" "$INCLUDES/usr/local/bin/identity-kiosk" mkdir -p "$INCLUDES/etc/default" cat > "$INCLUDES/etc/default/keyboard" < "$INCLUDES/home/${KIOSK_USERNAME}/.ssh/authorized_keys" chmod 600 "$INCLUDES/home/${KIOSK_USERNAME}/.ssh/authorized_keys" echo " Baked an SSH authorized_keys entry for ${KIOSK_USERNAME}." else echo " No SSH_AUTHORIZED_KEY set — SSH admin access will not be possible on this image." fi # --------------------------------------------------------------------------- # 2. Runtime config # --------------------------------------------------------------------------- echo "--- Writing /etc/door-panel-agent/config.env into includes.chroot ---" cat > "$INCLUDES/etc/door-panel-agent/config.env" <' and confirm it works." fi echo echo "Then pull the power on the container host and re-check: the panel must still" echo "boot (the dashboard will show connection errors, which is the expected degraded" echo "state — same acceptance already documented for hosts/touch-panel's Home" echo "workspace and hosts/kitchen-display's Scan/Inventory/Recipes tabs)." echo echo "Rebuilding later: edit hosts/door-panel/configs/* or agent/*, then re-run this" echo "script — includes.chroot is regenerated from them every time."