2025-07-22 10:29:28 +01:00

51 lines
944 B
Bash
Executable File

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