47 lines
953 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 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
cat > "/etc/NetworkManager/system-connections/${WIFI_SSID}.nmconnection" << EOF
[connection]
id=${WIFI_SSID}
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
chmod 600 "/etc/NetworkManager/system-connections/${WIFI_SSID}.nmconnection"
chown root:root "/etc/NetworkManager/system-connections/${WIFI_SSID}.nmconnection"
2025-07-22 08:42:22 +01:00
2025-07-22 09:24:31 +01:00
echo "Successfully created connection profile for ${WIFI_SSID}."