N/A
This commit is contained in:
@@ -150,33 +150,73 @@ log "Konfigurerar Wi-Fi"
|
|||||||
|
|
||||||
systemctl enable --now NetworkManager.service
|
systemctl enable --now NetworkManager.service
|
||||||
|
|
||||||
# Remove an old profile with the same name, then create a clean one.
|
# Configure Wi-Fi without requiring the hotspot to be visible right now.
|
||||||
nmcli connection delete "$WIFI_CONNECTION" >/dev/null 2>&1 || true
|
# 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
|
||||||
nmcli device wifi connect "$WIFI_SSID" \
|
WIFI_IF="$(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "wifi" {print $1; exit}')"
|
||||||
password "$WIFI_PASSWORD" \
|
[[ -n "$WIFI_IF" ]] || die "Hittade inget Wi-Fi-interface."
|
||||||
name "$WIFI_CONNECTION"
|
|
||||||
|
# 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 add type wifi \
|
||||||
|
ifname "$WIFI_IF" \
|
||||||
|
con-name "$WIFI_CONNECTION" \
|
||||||
|
ssid "$WIFI_SSID" \
|
||||||
|
wifi-sec.key-mgmt wpa-psk \
|
||||||
|
wifi-sec.psk "$WIFI_PASSWORD" \
|
||||||
|
ipv4.method auto \
|
||||||
|
ipv4.never-default yes \
|
||||||
|
ipv4.route-metric 600 \
|
||||||
|
ipv6.method disabled
|
||||||
|
|
||||||
nmcli connection modify "$WIFI_CONNECTION" \
|
nmcli connection modify "$WIFI_CONNECTION" \
|
||||||
connection.autoconnect yes \
|
connection.autoconnect yes \
|
||||||
connection.autoconnect-retries 0 \
|
connection.autoconnect-retries 0 \
|
||||||
|
connection.autoconnect-priority 100 \
|
||||||
connection.mdns 0 \
|
connection.mdns 0 \
|
||||||
ipv4.never-default yes \
|
ipv4.never-default yes \
|
||||||
ipv4.route-metric 600 \
|
ipv4.route-metric 600 \
|
||||||
ipv6.method disabled \
|
ipv6.method disabled \
|
||||||
ipv6.never-default yes
|
ipv6.never-default yes
|
||||||
|
|
||||||
# Give the hotspot connection high priority if several Wi-Fi networks are known.
|
# Try immediately, but do not abort the installation if the A50 hotspot is
|
||||||
nmcli connection modify "$WIFI_CONNECTION" connection.autoconnect-priority 100
|
# currently off or temporarily not visible.
|
||||||
|
if nmcli connection up "$WIFI_CONNECTION"; then
|
||||||
|
log "Wi-Fi anslutet till $WIFI_SSID"
|
||||||
|
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."
|
||||||
|
fi
|
||||||
|
|
||||||
nmcli connection up "$WIFI_CONNECTION" || true
|
# Wired Ethernet is the maintenance/Internet path. Ensure every currently
|
||||||
|
# known Ethernet profile prefers a normal DHCP default route with a low metric.
|
||||||
|
while IFS=: read -r CON_NAME CON_TYPE; do
|
||||||
|
[[ "$CON_TYPE" == "802-3-ethernet" ]] || continue
|
||||||
|
nmcli connection modify "$CON_NAME" \
|
||||||
|
ipv4.never-default no \
|
||||||
|
ipv4.route-metric 100 \
|
||||||
|
ipv6.never-default no \
|
||||||
|
connection.autoconnect yes || true
|
||||||
|
done < <(nmcli -t -f NAME,TYPE connection show)
|
||||||
|
|
||||||
# Wired Ethernet is the maintenance/Internet path. Do not create a special
|
# Create a DHCP Ethernet profile for each physical Ethernet interface that
|
||||||
# Ethernet profile: NetworkManager's normal DHCP profile should be allowed to
|
# currently has no suitable profile. This makes plugging in a cable later
|
||||||
# obtain a default route whenever a cable is connected. The Wi-Fi profile has
|
# reliably provide the maintenance/Internet path.
|
||||||
# never-default enabled above, so Ethernet wins the default route naturally.
|
while read -r ETH_IF; do
|
||||||
# Existing Ethernet profiles are left untouched.
|
[[ -n "$ETH_IF" ]] || continue
|
||||||
|
PROFILE="Fikakassa-Ethernet-$ETH_IF"
|
||||||
|
if ! nmcli -t -f NAME connection show | grep -Fxq "$PROFILE"; then
|
||||||
|
nmcli connection add type ethernet \
|
||||||
|
ifname "$ETH_IF" \
|
||||||
|
con-name "$PROFILE" \
|
||||||
|
ipv4.method auto \
|
||||||
|
ipv4.never-default no \
|
||||||
|
ipv4.route-metric 100 \
|
||||||
|
ipv6.method auto \
|
||||||
|
ipv6.never-default no \
|
||||||
|
connection.autoconnect yes >/dev/null
|
||||||
|
fi
|
||||||
|
done < <(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "ethernet" {print $1}')
|
||||||
|
|
||||||
log "Konfigurerar lokal brandvägg"
|
log "Konfigurerar lokal brandvägg"
|
||||||
|
|
||||||
@@ -295,6 +335,14 @@ EOF
|
|||||||
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
|
||||||
|
# startup quirks.
|
||||||
|
cat > /usr/local/bin/fikakassa-startx <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
exec /usr/bin/startx
|
||||||
|
EOF
|
||||||
|
chmod 755 /usr/local/bin/fikakassa-startx
|
||||||
|
|
||||||
cat > "$KIOSK_HOME/.config/openbox/autostart" <<EOF
|
cat > "$KIOSK_HOME/.config/openbox/autostart" <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
@@ -342,9 +390,9 @@ EOF
|
|||||||
|
|
||||||
# Start X only on tty1 for the kiosk account.
|
# Start X only on tty1 for the kiosk account.
|
||||||
cat > "$KIOSK_HOME/.bash_profile" <<'EOF'
|
cat > "$KIOSK_HOME/.bash_profile" <<'EOF'
|
||||||
# Start graphical kiosk session automatically.
|
# 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 startx
|
exec /usr/local/bin/fikakassa-startx
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.bash_profile"
|
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.bash_profile"
|
||||||
@@ -352,8 +400,16 @@ chmod 644 "$KIOSK_HOME/.bash_profile"
|
|||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable getty@tty1.service
|
systemctl enable getty@tty1.service
|
||||||
systemctl restart getty@tty1.service || true
|
|
||||||
|
|
||||||
|
# Validate the files before restarting tty1. This is intentionally fatal: a
|
||||||
|
# kiosk without its graphical startup should not silently fall back to tty.
|
||||||
|
test -x "$KIOSK_HOME/.xinitrc"
|
||||||
|
test -x "$KIOSK_HOME/.config/openbox/autostart"
|
||||||
|
test -f "$KIOSK_HOME/.bash_profile"
|
||||||
|
test -x /usr/local/bin/fikakassa-startx
|
||||||
|
|
||||||
|
# Restarting getty will log the current terminal user out. This is expected
|
||||||
|
# when the script is run interactively on tty1.
|
||||||
log "Sätter systemtid/NTP"
|
log "Sätter systemtid/NTP"
|
||||||
|
|
||||||
# systemd-timesyncd is enough; no Internet browsing is required.
|
# systemd-timesyncd is enough; no Internet browsing is required.
|
||||||
@@ -363,8 +419,7 @@ systemctl enable --now systemd-timesyncd.service || true
|
|||||||
log "Aktiverar automatisk omstart av Chromium om X-sessionen kraschar"
|
log "Aktiverar automatisk omstart av Chromium om X-sessionen kraschar"
|
||||||
|
|
||||||
# Xorg/startx returns to tty1 if Chromium/Openbox dies. systemd getty will
|
# Xorg/startx returns to tty1 if Chromium/Openbox dies. systemd getty will
|
||||||
# respawn the session. This keeps the kiosk self-healing after crashes.
|
# respawn the login shell, which starts X again through .bash_profile.
|
||||||
systemctl restart getty@tty1.service || true
|
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user