mirror of
https://github.com/karl0ss/AnotterKiosk.git
synced 2025-10-25 04:33:58 +01:00
47 lines
953 B
Bash
Executable File
47 lines
953 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
|
|
|
|
# Generate a UUID for the connection
|
|
UUID=$(uuidgen)
|
|
|
|
# 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
|
|
|
|
[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 "/etc/NetworkManager/system-connections/${WIFI_SSID}.nmconnection"
|
|
chown root:root "/etc/NetworkManager/system-connections/${WIFI_SSID}.nmconnection"
|
|
|
|
echo "Successfully created connection profile for ${WIFI_SSID}."
|