This commit is contained in:
Joakim
2026-11-01 16:54:54 +01:00
parent fdeeb26e86
commit 2c7653bc4c

View File

@@ -9,15 +9,16 @@ set -Eeuo pipefail
# #
# The script: # The script:
# - installs the kiosk stack and Python runtime # - installs the kiosk stack and Python runtime
# - creates a non-admin kiosk user # - uses the existing Debian user as the kiosk user
# - installs the Fikakassan app from the directory containing this script # - installs the Fikakassan app from the directory containing this script
# - starts FastAPI automatically at boot # - starts FastAPI automatically at boot
# - configures Wi-Fi through NetworkManager # - configures Wi-Fi through NetworkManager
# - autologins the kiosk user # - autologins the kiosk user
# - starts Chromium in true kiosk mode # - starts Chromium in true kiosk mode
# - disables suspend/blanking and common escape routes # - disables suspend/blanking and common escape routes
# - limits outbound traffic so the kiosk does not use the phone's # - blocks ordinary Internet traffic over the Wi-Fi hotspot while allowing
# mobile data for normal Internet traffic; DNS/NTP are still allowed # full Internet access over wired Ethernet when a cable is connected
# - keeps Wi-Fi and Ethernet connected simultaneously
# #
# Before running, put this script in the root of the Fikakassan project. # Before running, put this script in the root of the Fikakassan project.
@@ -77,14 +78,14 @@ systemctl enable NetworkManager.service
systemctl enable ssh.service systemctl enable ssh.service
systemctl enable nftables.service systemctl enable nftables.service
log "Skapar kiosk-användare" log "Kontrollerar kiosk-användare"
if ! id "$KIOSK_USER" >/dev/null 2>&1; then if ! id "$KIOSK_USER" >/dev/null 2>&1; then
useradd --create-home --shell /bin/bash --user-group "$KIOSK_USER" die "Användaren '$KIOSK_USER' finns inte. Skapa användaren först eller ange KIOSK_USER=..."
fi fi
# Use the existing Debian user for the kiosk session. Existing sudo/group # Use the existing Debian user for the kiosk session. Do not alter its
# memberships are preserved. # existing group memberships or sudo permissions.
usermod -s /bin/bash "$KIOSK_USER" usermod -s /bin/bash "$KIOSK_USER"
log "Installerar Fikakassan i $APP_DIR" log "Installerar Fikakassan i $APP_DIR"
@@ -103,8 +104,16 @@ find "$APP_DIR" -type f -exec chmod 644 {} +
log "Skapar Python virtualenv" log "Skapar Python virtualenv"
rm -rf "$APP_DIR/.venv"
python3 -m venv "$APP_DIR/.venv" python3 -m venv "$APP_DIR/.venv"
"$APP_DIR/.venv/bin/pip" install --disable-pip-version-check --no-cache-dir -r "$APP_DIR/requirements.txt"
# Do not execute the pip wrapper directly. Some Debian filesystems/policies
# can leave the wrapper without execute permission. Running pip through the
# virtualenv Python avoids that failure.
"$APP_DIR/.venv/bin/python" -m pip install \
--disable-pip-version-check \
--no-cache-dir \
-r "$APP_DIR/requirements.txt"
log "Skapar systemd-tjänst för Fikakassan" log "Skapar systemd-tjänst för Fikakassan"
@@ -163,6 +172,12 @@ nmcli connection modify "$WIFI_CONNECTION" connection.autoconnect-priority 100
nmcli connection up "$WIFI_CONNECTION" || true nmcli connection up "$WIFI_CONNECTION" || true
# Wired Ethernet is the maintenance/Internet path. Do not create a special
# Ethernet profile: NetworkManager's normal DHCP profile should be allowed to
# obtain a default route whenever a cable is connected. The Wi-Fi profile has
# never-default enabled above, so Ethernet wins the default route naturally.
# Existing Ethernet profiles are left untouched.
log "Konfigurerar lokal brandvägg" log "Konfigurerar lokal brandvägg"
if [[ "$LOCK_DOWN_INTERNET" == "1" ]]; then if [[ "$LOCK_DOWN_INTERNET" == "1" ]]; then