Skip to content

Commit

Permalink
If wifi credentials are available, create a client config
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbakken committed Jun 26, 2024
1 parent ef83e7e commit 53a8770
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions userpatches/overlay/autohotspot/autohotspot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

. /etc/rebuild-settings
wifidev=`nmcli dev | grep "wifi " | cut -d' ' -f1`
hotspot_SSID="Recore"
hotspot_PW="12345678"
Expand All @@ -18,7 +19,20 @@ create_hotspot() {
nmcli con modify Hotspot wifi-sec.psk "$hotspot_PW"
}

if [ ! -f /etc/NetworkManager/system-connections/Hotspot.nmconnection ]
then
create_client() {
echo "Creating wifi client config"
nmcli con add type wifi ifname "$wifidev" con-name Client ssid "$WIFI_SSID"
nmcli con modify Client wifi-sec.key-mgmt wpa-psk
nmcli con modify Client wifi-sec.psk "$WIFI_PSK"
nmcli con up Client
}

if [ ! -f /etc/NetworkManager/system-connections/Hotspot.nmconnection ]; then
create_hotspot
fi

if [ ! -f /etc/NetworkManager/system-connections/Client.nmconnection ]; then
if [ "${WIFI_SSID}" != "" ]; then
create_client
fi
fi

0 comments on commit 53a8770

Please sign in to comment.