51 lines
944 B
Plaintext
Raw Normal View History

2023-06-29 22:14:05 +02:00
#!/bin/bash
2025-07-22 09:24:31 +01:00
set -e
2023-06-29 22:14:05 +02:00
2025-07-22 09:24:31 +01:00
echo "Generating NetworkManager connection profile..."
2025-07-22 08:39:09 +01:00
2023-06-29 22:14:05 +02:00
WIFI_SSID=$(get-ini /boot/kioskbrowser.ini wifi ssid)
WIFI_PSK=$(get-ini /boot/kioskbrowser.ini wifi psk)
2025-07-22 08:42:22 +01:00
if [ -z "${WIFI_SSID}" ]; then
echo "No WiFi SSID configured. Exiting."
exit 0
2023-06-29 22:14:05 +02:00
fi
2025-07-22 10:29:28 +01:00
# The profile will be written to /tmp and symlinked from /etc
PROFILE_NAME="kiosk"
PROFILE_PATH="/tmp/${PROFILE_NAME}.nmconnection"
2025-07-22 09:24:31 +01:00
# Generate a UUID for the connection
UUID=$(uuidgen)
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
# Create the NetworkManager connection file
2025-07-22 10:29:28 +01:00
cat > "${PROFILE_PATH}" << EOF
2025-07-22 09:24:31 +01:00
[connection]
2025-07-22 10:29:28 +01:00
id=${PROFILE_NAME}
2025-07-22 09:24:31 +01:00
uuid=${UUID}
type=wifi
interface-name=wlan0
autoconnect=true
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
[wifi]
mode=infrastructure
ssid=${WIFI_SSID}
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=${WIFI_PSK}
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
[ipv4]
method=auto
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
[ipv6]
method=auto
EOF
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
# Set the correct permissions
2025-07-22 10:29:28 +01:00
chmod 600 "${PROFILE_PATH}"
chown root:root "${PROFILE_PATH}"
2025-07-22 08:42:22 +01:00
2025-07-22 10:29:28 +01:00
echo "Successfully created connection profile at ${PROFILE_PATH}."