This commit is contained in:
Joakim
2026-11-01 17:33:21 +01:00
parent 9e12762be4
commit dafc37df96

View File

@@ -1,47 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -Eeuo pipefail set -Eeuo pipefail
# Fikakassan kiosk setup # Fikakassan kiosk setup - V5
# Debian 13 / X11 / Openbox / Chromium / NetworkManager # Debian 13 / X11 / Openbox / Chromium / NetworkManager
# #
# Run as root: # V5 adds automatic display + touchscreen rotation using iio-sensor-proxy.
# sudo ./setup-kiosk.sh # It is designed to be rerunnable on an already partially configured V4 host.
#
# The script:
# - installs the kiosk stack and Python runtime
# - uses the existing Debian user as the kiosk user
# - installs the Fikakassan app from the directory containing this script
# - starts FastAPI automatically at boot
# - configures Wi-Fi through NetworkManager
# - autologins the kiosk user
# - starts Chromium in true kiosk mode
# - disables suspend/blanking and common escape routes
# - blocks ordinary Internet traffic over the Wi-Fi hotspot while allowing
# 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.
KIOSK_USER="${KIOSK_USER:-joakim}" KIOSK_USER="${KIOSK_USER:-joakim}"
APP_DIR="${APP_DIR:-/opt/fikakassa}" APP_DIR="${APP_DIR:-/opt/fikakassa}"
KIOSK_URL="${KIOSK_URL:-http://127.0.0.1:8000/}" KIOSK_URL="${KIOSK_URL:-http://127.0.0.1:8000/}"
WIFI_CONNECTION="${WIFI_CONNECTION:-Fikakassa-WiFi}"
WIFI_CONNECTION="${WIFI_CONNECTION:-Fikakassan-WiFi}"
WIFI_SSID="${WIFI_SSID:-}" WIFI_SSID="${WIFI_SSID:-}"
WIFI_PASSWORD="${WIFI_PASSWORD:-}" WIFI_PASSWORD="${WIFI_PASSWORD:-}"
# Set to 0 if you explicitly want ordinary Internet access from the kiosk.
LOCK_DOWN_INTERNET="${LOCK_DOWN_INTERNET:-1}" LOCK_DOWN_INTERNET="${LOCK_DOWN_INTERNET:-1}"
log() { printf '\n\033[1;32m==> %s\033[0m\n' "$*"; } log() { printf '\n\033[1;32m==> %s\033[0m\n' "$*"; }
warn() { printf '\n\033[1;33mWARNING: %s\033[0m\n' "$*" >&2; } warn() { printf '\n\033[1;33mWARNING: %s\033[0m\n' "$*" >&2; }
die() { printf '\n\033[1;31mERROR: %s\033[0m\n' "$*" >&2; exit 1; } die() { printf '\n\033[1;31mERROR: %s\033[0m\n' "$*" >&2; exit 1; }
[[ $EUID -eq 0 ]] || die "Kör skriptet som root eller med sudo." [[ $EUID -eq 0 ]] || die "Kör skriptet med sudo."
command -v apt-get >/dev/null || die "Det här skriptet är avsett för Debian/derivat med apt." command -v apt-get >/dev/null || die "Det här skriptet kräver Debian/apt."
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
[[ -f "$SCRIPT_DIR/app/main.py" ]] || die "app/main.py saknas. Kör skriptet från Fikakassans projektkatalog." [[ -f "$SCRIPT_DIR/app/main.py" ]] || die "app/main.py saknas. Kör skriptet från Fikakassans projektkatalog."
[[ -f "$SCRIPT_DIR/requirements.txt" ]] || die "requirements.txt saknas." [[ -f "$SCRIPT_DIR/requirements.txt" ]] || die "requirements.txt saknas."
@@ -54,7 +35,6 @@ if [[ -z "$WIFI_PASSWORD" ]]; then
fi fi
log "Installerar systempaket" log "Installerar systempaket"
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
apt-get update apt-get update
apt-get install -y \ apt-get install -y \
@@ -69,55 +49,43 @@ apt-get install -y \
chromium \ chromium \
unclutter \ unclutter \
x11-xserver-utils \ x11-xserver-utils \
xinput \
iio-sensor-proxy \
fonts-dejavu \ fonts-dejavu \
fonts-liberation \ fonts-liberation \
nftables \ nftables \
rsync rsync \
systemd-timesyncd
systemctl enable NetworkManager.service systemctl enable NetworkManager.service
systemctl enable ssh.service systemctl enable ssh.service
systemctl enable nftables.service systemctl enable nftables.service
systemctl enable systemd-timesyncd.service || true
log "Kontrollerar kiosk-användare" log "Kontrollerar kiosk-användare"
id "$KIOSK_USER" >/dev/null 2>&1 || die "Användaren '$KIOSK_USER' finns inte."
if ! id "$KIOSK_USER" >/dev/null 2>&1; then
die "Användaren '$KIOSK_USER' finns inte. Skapa användaren först eller ange KIOSK_USER=..."
fi
# Use the existing Debian user for the kiosk session. Do not alter its
# existing group memberships or sudo permissions.
usermod -s /bin/bash "$KIOSK_USER" usermod -s /bin/bash "$KIOSK_USER"
KIOSK_HOME="$(getent passwd "$KIOSK_USER" | cut -d: -f6)"
[[ -d "$KIOSK_HOME" ]] || die "Hittade inte hemkatalogen för $KIOSK_USER."
log "Installerar Fikakassan i $APP_DIR" log "Installerar Fikakassan i $APP_DIR"
install -d -o root -g root "$APP_DIR" install -d -o root -g root "$APP_DIR"
rsync -a --delete \ rsync -a --delete \
--exclude='.venv/' \ --exclude='.venv/' \
--exclude='__pycache__/' \ --exclude='__pycache__/' \
--exclude='*.pyc' \ --exclude='*.pyc' \
"$SCRIPT_DIR/" "$APP_DIR/" "$SCRIPT_DIR/" "$APP_DIR/"
# The kiosk user needs to read the application, but not modify it.
chown -R root:root "$APP_DIR" chown -R root:root "$APP_DIR"
find "$APP_DIR" -type d -exec chmod 755 {} + find "$APP_DIR" -type d -exec chmod 755 {} +
find "$APP_DIR" -type f -exec chmod 644 {} + find "$APP_DIR" -type f -exec chmod 644 {} +
log "Skapar Python virtualenv" log "Skapar Python virtualenv"
rm -rf "$APP_DIR/.venv" rm -rf "$APP_DIR/.venv"
python3 -m venv "$APP_DIR/.venv" python3 -m venv "$APP_DIR/.venv"
"$APP_DIR/.venv/bin/python" -m 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"
cat > /etc/systemd/system/fikakassa.service <<EOF2
cat > /etc/systemd/system/fikakassa.service <<EOF
[Unit] [Unit]
Description=Fikakassan FastAPI Description=Fikakassan FastAPI
After=network-online.target After=network-online.target
@@ -140,24 +108,16 @@ ReadWritePaths=$APP_DIR/data
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF2
install -d -m 755 "$APP_DIR/data" install -d -m 755 "$APP_DIR/data"
systemctl daemon-reload systemctl daemon-reload
systemctl enable --now fikakassa.service systemctl enable --now fikakassa.service
log "Konfigurerar Wi-Fi" log "Konfigurerar Wi-Fi"
systemctl enable --now NetworkManager.service systemctl enable --now NetworkManager.service
# Configure Wi-Fi without requiring the hotspot to be visible right now.
# The phone may be switched off during installation; NetworkManager will
# reconnect automatically when the SSID becomes available later.
nmcli radio wifi on nmcli radio wifi on
WIFI_IF="$(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "wifi" {print $1; exit}')" WIFI_IF="$(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "wifi" {print $1; exit}')"
[[ -n "$WIFI_IF" ]] || die "Hittade inget Wi-Fi-interface." [[ -n "$WIFI_IF" ]] || die "Hittade inget Wi-Fi-interface."
# Remove an old profile with the same name, then create a persistent profile.
nmcli connection delete "$WIFI_CONNECTION" >/dev/null 2>&1 || true nmcli connection delete "$WIFI_CONNECTION" >/dev/null 2>&1 || true
nmcli connection add type wifi \ nmcli connection add type wifi \
ifname "$WIFI_IF" \ ifname "$WIFI_IF" \
@@ -168,8 +128,7 @@ nmcli connection add type wifi \
ipv4.method auto \ ipv4.method auto \
ipv4.never-default yes \ ipv4.never-default yes \
ipv4.route-metric 600 \ ipv4.route-metric 600 \
ipv6.method disabled ipv6.method disabled >/dev/null
nmcli connection modify "$WIFI_CONNECTION" \ nmcli connection modify "$WIFI_CONNECTION" \
connection.autoconnect yes \ connection.autoconnect yes \
connection.autoconnect-retries 0 \ connection.autoconnect-retries 0 \
@@ -179,17 +138,13 @@ nmcli connection modify "$WIFI_CONNECTION" \
ipv4.route-metric 600 \ ipv4.route-metric 600 \
ipv6.method disabled \ ipv6.method disabled \
ipv6.never-default yes ipv6.never-default yes
# Try immediately, but do not abort the installation if the A50 hotspot is
# currently off or temporarily not visible.
if nmcli connection up "$WIFI_CONNECTION"; then if nmcli connection up "$WIFI_CONNECTION"; then
log "Wi-Fi anslutet till $WIFI_SSID" log "Wi-Fi anslutet till $WIFI_SSID"
else else
warn "Wi-Fi-hotspotten '$WIFI_SSID' är inte tillgänglig just nu. Profilen är skapad och kommer att återansluta automatiskt när hotspotten startas." warn "Wi-Fi-hotspotten '$WIFI_SSID' är inte tillgänglig just nu. Profilen är skapad och återansluter automatiskt senare."
fi fi
# Wired Ethernet is the maintenance/Internet path. Ensure every currently log "Konfigurerar Ethernet"
# known Ethernet profile prefers a normal DHCP default route with a low metric.
while IFS=: read -r CON_NAME CON_TYPE; do while IFS=: read -r CON_NAME CON_TYPE; do
[[ "$CON_TYPE" == "802-3-ethernet" ]] || continue [[ "$CON_TYPE" == "802-3-ethernet" ]] || continue
nmcli connection modify "$CON_NAME" \ nmcli connection modify "$CON_NAME" \
@@ -198,10 +153,6 @@ while IFS=: read -r CON_NAME CON_TYPE; do
ipv6.never-default no \ ipv6.never-default no \
connection.autoconnect yes || true connection.autoconnect yes || true
done < <(nmcli -t -f NAME,TYPE connection show) done < <(nmcli -t -f NAME,TYPE connection show)
# Create a DHCP Ethernet profile for each physical Ethernet interface that
# currently has no suitable profile. This makes plugging in a cable later
# reliably provide the maintenance/Internet path.
while read -r ETH_IF; do while read -r ETH_IF; do
[[ -n "$ETH_IF" ]] || continue [[ -n "$ETH_IF" ]] || continue
PROFILE="Fikakassa-Ethernet-$ETH_IF" PROFILE="Fikakassa-Ethernet-$ETH_IF"
@@ -219,97 +170,54 @@ while read -r ETH_IF; do
done < <(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "ethernet" {print $1}') done < <(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "ethernet" {print $1}')
log "Konfigurerar lokal brandvägg" log "Konfigurerar lokal brandvägg"
if [[ "$LOCK_DOWN_INTERNET" == "1" ]]; then if [[ "$LOCK_DOWN_INTERNET" == "1" ]]; then
# The kiosk needs: cat > /etc/nftables.conf <<'EOF2'
# - local LAN traffic to the A50/kiosk
# - DNS for NTP hostname resolution
# - UDP/123 for NTP
# - DHCP
# - established traffic
#
# It must NOT be able to browse the Internet through the phone.
# A wired Ethernet connection (interface names en*) is intentionally
# exempted from the outbound lockdown, so plugging in a cable gives
# normal Internet access for updates and development while Wi-Fi remains
# available for the A50/local kiosk network.
#
# All RFC1918 traffic is permitted so the Android bridge can talk to the
# kiosk even if Samsung changes the hotspot subnet.
cat > /etc/nftables.conf <<'EOF'
#!/usr/sbin/nft -f #!/usr/sbin/nft -f
flush ruleset flush ruleset
table inet kiosk_filter { table inet kiosk_filter {
chain input { chain input {
type filter hook input priority filter; policy drop; type filter hook input priority filter; policy drop;
iifname "lo" accept iifname "lo" accept
ct state established,related accept ct state established,related accept
# ICMP is useful for diagnostics and does not provide Internet browsing.
ip protocol icmp accept ip protocol icmp accept
# DHCP client traffic.
udp sport 67 udp dport 68 accept udp sport 67 udp dport 68 accept
# SSH and Fikakassan are available from the local network only.
ip saddr 10.0.0.0/8 tcp dport 22 accept ip saddr 10.0.0.0/8 tcp dport 22 accept
ip saddr 172.16.0.0/12 tcp dport 22 accept ip saddr 172.16.0.0/12 tcp dport 22 accept
ip saddr 192.168.0.0/16 tcp dport 22 accept ip saddr 192.168.0.0/16 tcp dport 22 accept
ip saddr 10.0.0.0/8 tcp dport 8000 accept ip saddr 10.0.0.0/8 tcp dport 8000 accept
ip saddr 172.16.0.0/12 tcp dport 8000 accept ip saddr 172.16.0.0/12 tcp dport 8000 accept
ip saddr 192.168.0.0/16 tcp dport 8000 accept ip saddr 192.168.0.0/16 tcp dport 8000 accept
} }
chain forward { chain forward {
type filter hook forward priority filter; policy drop; type filter hook forward priority filter; policy drop;
} }
chain output { chain output {
type filter hook output priority filter; policy drop; type filter hook output priority filter; policy drop;
oifname "lo" accept oifname "lo" accept
ct state established,related accept ct state established,related accept
# DHCP client.
udp sport 68 udp dport 67 accept udp sport 68 udp dport 67 accept
# A wired Ethernet connection is the maintenance/Internet path.
# Allow normal outbound traffic there; Wi-Fi remains locked to local
# networks plus DNS/NTP.
oifname "en*" accept oifname "en*" accept
# DNS and NTP are explicitly allowed.
udp dport 53 accept udp dport 53 accept
tcp dport 53 accept tcp dport 53 accept
udp dport 123 accept udp dport 123 accept
# Permit local/private networks only.
ip daddr 10.0.0.0/8 accept ip daddr 10.0.0.0/8 accept
ip daddr 172.16.0.0/12 accept ip daddr 172.16.0.0/12 accept
ip daddr 192.168.0.0/16 accept ip daddr 192.168.0.0/16 accept
# ICMP for local diagnostics.
ip daddr 10.0.0.0/8 ip protocol icmp accept ip daddr 10.0.0.0/8 ip protocol icmp accept
ip daddr 172.16.0.0/12 ip protocol icmp accept ip daddr 172.16.0.0/12 ip protocol icmp accept
ip daddr 192.168.0.0/16 ip protocol icmp accept ip daddr 192.168.0.0/16 ip protocol icmp accept
} }
} }
EOF EOF2
nft -f /etc/nftables.conf
nft -f /etc/nftables.conf
else else
warn "Internet-lockdown är avstängt (LOCK_DOWN_INTERNET=0)." warn "Internet-lockdown är avstängt (LOCK_DOWN_INTERNET=0)."
fi fi
log "Stänger av automatisk sleep/blanking" log "Stänger av sleep/blanking"
mkdir -p /etc/systemd/logind.conf.d mkdir -p /etc/systemd/logind.conf.d
cat > /etc/systemd/logind.conf.d/90-fikakassa.conf <<'EOF' cat > /etc/systemd/logind.conf.d/90-fikakassa.conf <<'EOF2'
[Login] [Login]
HandlePowerKey=ignore HandlePowerKey=ignore
HandleSuspendKey=ignore HandleSuspendKey=ignore
@@ -317,114 +225,175 @@ HandleHibernateKey=ignore
HandleLidSwitch=ignore HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore HandleLidSwitchExternalPower=ignore
IdleAction=ignore IdleAction=ignore
EOF EOF2
systemctl restart systemd-logind.service || true systemctl restart systemd-logind.service || true
log "Konfigurerar X11/Openbox" log "Konfigurerar X11/Openbox"
install -d -o "$KIOSK_USER" -g "$KIOSK_USER" "$KIOSK_HOME/.config/openbox" "$KIOSK_HOME/.config"
KIOSK_HOME="/home/$KIOSK_USER" cat > "$KIOSK_HOME/.xinitrc" <<'EOF2'
install -d -o "$KIOSK_USER" -g "$KIOSK_USER" \
"$KIOSK_HOME/.config/openbox" \
"$KIOSK_HOME/.config"
cat > "$KIOSK_HOME/.xinitrc" <<'EOF'
#!/bin/sh #!/bin/sh
exec openbox-session exec openbox-session
EOF EOF2
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.xinitrc" chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.xinitrc"
chmod 755 "$KIOSK_HOME/.xinitrc" chmod 755 "$KIOSK_HOME/.xinitrc"
# A small explicit launcher makes the kiosk session independent of shell cat > /usr/local/bin/fikakassa-startx <<'EOF2'
# startup quirks.
cat > /usr/local/bin/fikakassa-startx <<EOF
#!/bin/sh #!/bin/sh
exec /usr/bin/startx exec /usr/bin/startx
EOF EOF2
chmod 755 /usr/local/bin/fikakassa-startx chmod 755 /usr/local/bin/fikakassa-startx
cat > "$KIOSK_HOME/.config/openbox/autostart" <<EOF # Orientation helper. It uses the accelerometer exposed through
# iio-sensor-proxy and rotates both the internal display and touchscreen.
cat > /usr/local/bin/fikakassa-orientation <<'EOF2'
#!/bin/sh #!/bin/sh
set -u
# Disable screen blanking and DPMS. DISPLAY=:0
export DISPLAY
USER_NAME="${SUDO_USER:-joakim}"
USER_HOME="$(getent passwd "$USER_NAME" | cut -d: -f6 2>/dev/null || echo /home/joakim)"
export XAUTHORITY="$USER_HOME/.Xauthority"
get_output() {
xrandr --query 2>/dev/null | awk '/ connected/{print $1; exit}'
}
set_touch_matrix() {
orientation="$1"
# Find likely touchscreen devices. Some X1 Yoga revisions expose names
# containing ELAN, Wacom or Touchscreen.
for id in $(xinput --list --id-only 2>/dev/null); do
name="$(xinput --list --name-only 2>/dev/null | sed -n "${id}p" 2>/dev/null || true)"
props="$(xinput list-props "$id" 2>/dev/null || true)"
if printf '%s\n' "$props" | grep -qi 'Coordinate Transformation Matrix'; then
label="$(xinput list --name-only 2>/dev/null | head -n "$((id + 1))" | tail -n 1 2>/dev/null || true)"
if printf '%s\n%s\n' "$name" "$label" | grep -Eqi 'touchscreen|touch screen|ELAN|Wacom|Touch'; then
case "$orientation" in
normal|undefined)
matrix='1 0 0 0 1 0 0 0 1' ;;
bottom-up)
matrix='-1 0 1 0 -1 1 0 0 1' ;;
left-up)
matrix='0 -1 1 1 0 0 0 0 1' ;;
right-up)
matrix='0 1 0 -1 0 1 0 0 1' ;;
*)
matrix='1 0 0 0 1 0 0 0 1' ;;
esac
xinput set-prop "$id" 'Coordinate Transformation Matrix' $matrix 2>/dev/null || true
fi
fi
done
}
apply_orientation() {
orientation="$1"
output="$(get_output)"
[ -n "$output" ] || return 0
case "$orientation" in
normal|undefined)
rotation=normal ;;
bottom-up)
rotation=inverted ;;
left-up)
rotation=left ;;
right-up)
rotation=right ;;
*)
rotation=normal ;;
esac
xrandr --output "$output" --rotate "$rotation" 2>/dev/null || true
set_touch_matrix "$orientation"
}
# Wait for X to be ready.
until xrandr --query >/dev/null 2>&1; do sleep 1; done
# monitor-sensor prints orientation changes. The first orientation line is
# normally emitted immediately after connecting to the sensor service.
monitor-sensor 2>/dev/null | while IFS= read -r line; do
case "$line" in
*"orientation changed:"*)
orientation="${line##*: }"
apply_orientation "$orientation"
;;
*"orientation:"*)
orientation="${line##*: }"
apply_orientation "$orientation"
;;
esac
done
EOF2
chmod 755 /usr/local/bin/fikakassa-orientation
cat > "$KIOSK_HOME/.config/openbox/autostart" <<EOF2
#!/bin/sh
xset s off xset s off
xset -dpms xset -dpms
xset s noblank xset s noblank
# Hide mouse cursor after a short delay.
unclutter --timeout 2 --jitter 5 --ignore-scrolling & unclutter --timeout 2 --jitter 5 --ignore-scrolling &
# Start the kiosk browser. # Start orientation watcher for Lenovo X1 Yoga.
exec chromium \\ /usr/local/bin/fikakassa-orientation >/tmp/fikakassa-orientation.log 2>&1 &
--kiosk \\
--start-fullscreen \\ exec chromium \
--no-first-run \\ --kiosk \
--no-default-browser-check \\ --start-fullscreen \
--disable-session-crashed-bubble \\ --no-first-run \
--disable-infobars \\ --no-default-browser-check \
--disable-translate \\ --disable-session-crashed-bubble \
--disable-features=TranslateUI \\ --disable-infobars \
--password-store=basic \\ --disable-translate \
--disable-pinch \\ --disable-features=TranslateUI \
--overscroll-history-navigation=0 \\ --password-store=basic \
--disable-background-networking \\ --disable-pinch \
--disable-component-update \\ --overscroll-history-navigation=0 \
--disable-domain-reliability \\ --disable-background-networking \
--disable-sync \\ --disable-component-update \
--metrics-recording-only \\ --disable-domain-reliability \
--noerrdialogs \\ --disable-sync \
--metrics-recording-only \
--noerrdialogs \
"$KIOSK_URL" "$KIOSK_URL"
EOF EOF2
chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config" chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config"
chmod 755 "$KIOSK_HOME/.config/openbox/autostart" chmod 755 "$KIOSK_HOME/.config/openbox/autostart"
log "Konfigurerar automatisk inloggning på tty1" log "Konfigurerar automatisk inloggning på tty1"
mkdir -p /etc/systemd/system/getty@tty1.service.d mkdir -p /etc/systemd/system/getty@tty1.service.d
cat > /etc/systemd/system/getty@tty1.service.d/override.conf <<EOF cat > /etc/systemd/system/getty@tty1.service.d/override.conf <<EOF2
[Service] [Service]
ExecStart= ExecStart=
ExecStart=-/sbin/agetty --autologin $KIOSK_USER --noclear %I \$TERM ExecStart=-/sbin/agetty --autologin $KIOSK_USER --noclear %I \\$TERM
Type=idle Type=idle
EOF EOF2
cat > "$KIOSK_HOME/.bash_profile" <<'EOF2'
# Start X only on tty1 for the kiosk account.
cat > "$KIOSK_HOME/.bash_profile" <<'EOF'
# Start graphical kiosk session automatically on tty1.
if [ -z "$DISPLAY" ] && [ "$(tty 2>/dev/null)" = "/dev/tty1" ]; then if [ -z "$DISPLAY" ] && [ "$(tty 2>/dev/null)" = "/dev/tty1" ]; then
exec /usr/local/bin/fikakassa-startx exec /usr/local/bin/fikakassa-startx
fi fi
EOF EOF2
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.bash_profile" chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.bash_profile"
chmod 644 "$KIOSK_HOME/.bash_profile" chmod 644 "$KIOSK_HOME/.bash_profile"
systemctl daemon-reload systemctl daemon-reload
systemctl enable getty@tty1.service systemctl enable getty@tty1.service
systemctl enable --now systemd-timesyncd.service || true
# Validate the files before restarting tty1. This is intentionally fatal: a log "Kontrollerar kioskfiler"
# kiosk without its graphical startup should not silently fall back to tty.
test -x "$KIOSK_HOME/.xinitrc" test -x "$KIOSK_HOME/.xinitrc"
test -x "$KIOSK_HOME/.config/openbox/autostart" test -x "$KIOSK_HOME/.config/openbox/autostart"
test -f "$KIOSK_HOME/.bash_profile" test -f "$KIOSK_HOME/.bash_profile"
test -x /usr/local/bin/fikakassa-startx test -x /usr/local/bin/fikakassa-startx
test -x /usr/local/bin/fikakassa-orientation
# Restarting getty will log the current terminal user out. This is expected cat <<EOF2
# when the script is run interactively on tty1.
log "Sätter systemtid/NTP"
# systemd-timesyncd is enough; no Internet browsing is required.
apt-get install -y systemd-timesyncd
systemctl enable --now systemd-timesyncd.service || true
log "Aktiverar automatisk omstart av Chromium om X-sessionen kraschar"
# Xorg/startx returns to tty1 if Chromium/Openbox dies. systemd getty will
# respawn the login shell, which starts X again through .bash_profile.
cat <<EOF
======================================== ========================================
FIKAKASSAN KIOSK ÄR KONFIGURERAD FIKAKASSAN KIOSK V5 ÄR KONFIGURERAD
======================================== ========================================
Kiosk-användare: $KIOSK_USER Kiosk-användare: $KIOSK_USER
@@ -433,30 +402,33 @@ Webbapp: $KIOSK_URL
Wi-Fi: $WIFI_SSID Wi-Fi: $WIFI_SSID
Wi-Fi-profil: $WIFI_CONNECTION Wi-Fi-profil: $WIFI_CONNECTION
FastAPI:
systemctl status fikakassa
journalctl -u fikakassa -f
SSH:
systemctl status ssh
Nätverk: Nätverk:
nmcli device status Wi-Fi = lokalt A50-nät, ingen default Internet-route
nmcli connection show Ethernet = normal Internet-route, metric 100
Kiosk: Kiosk:
tty1 autologin -> Xorg -> Openbox -> Chromium tty1 autologin -> Xorg -> Openbox -> Chromium
Internet-lockdown: Rotation:
$([[ "$LOCK_DOWN_INTERNET" == "1" ]] && echo "AKTIV: endast lokalt nät + DNS/NTP" || echo "AVSTÄNGD") iio-sensor-proxy + monitor-sensor
display + touchscreen roteras automatiskt
Starta om maskinen nu: FastAPI:
reboot systemctl status fikakassa
journalctl -u fikakassa -f
Orientation-logg:
/tmp/fikakassa-orientation.log
Starta om när du är klar:
sudo reboot
OBS: OBS:
"Power on efter strömavbrott" är en BIOS/UEFI-inställning och kan inte Om skärmen roteras men touch inte gör det korrekt, kontrollera:
garanteras av Linux. På X1 Yoga behöver "Power on with AC attach" / xinput list
motsvarande BIOS-inställning aktiveras om maskinen ska starta automatiskt och:
efter ett strömavbrott. cat /tmp/fikakassa-orientation.log
EOF Automatisk start efter strömavbrott kräver rätt BIOS/UEFI-inställning.
EOF2