Skip to content

Commit

Permalink
modified wifi network setup to check for a /boot/SetupWIFI file and in
Browse files Browse the repository at this point in the history
case it exists during bootup we generate the corresponding
/etc/config/wpa_supplicant.conf file automatically. This should allow to
setup a WIFI connection by just adding a file "SetupWIFI" to the FAT32
based boot partition (SSID in first line, Password on second line) and
the WiFi connection should then be automatically started upon start.
  • Loading branch information
jens-maus committed Oct 29, 2020
1 parent f0c6a7c commit eb7e360
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ case "${IFACE}" in

# start WPA Supplicant if this is a WiFi connection
wlan*)
# check if /boot/setupWiFi exists and contains the necessary
# data to generate /etc/config/wpa_supplicant.conf automatically
if [[ -s /boot/SetupWIFI ]]; then
SSID=$(head -1 /boot/SetupWIFI | dos2unix)
PWD=$(tail -1 /boot/SetupWIFI | dos2unix)
if [[ -n "${SSID}" ]] && [[ -n "${PWD}" ]]; then
cp /etc/config_templates/wpa_supplicant.conf >/etc/config/wpa_supplicant.conf
/usr/sbin/wpa_passphrase "${SSID}" "${PWD}" >>/etc/config/wpa_supplicant.conf
if [[ $? -eq 0 ]]; then
mount -o rw,remount /boot
rm -f /boot/SetupWIFI
mount -o ro,remount /boot
fi
fi
fi

# if /etc/config/wpa_supplicant.conf exists, bring up
# the WiFi connection.
if [[ -s /etc/config/wpa_supplicant.conf ]]; then
/sbin/ip link set ${IFACE} up
sleep 5
Expand Down

1 comment on commit eb7e360

@aksnet
Copy link

@aksnet aksnet commented on eb7e360 Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with Nightly Build RaspberryMatic-3.53.34.20201101-0ef9ec-rpi0.zip and working perfect. Thanks!

Please sign in to comment.