From 266c31e10a5439fc862134250e8378fafc2157e3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 26 Apr 2016 09:56:29 +0100 Subject: [PATCH] Improve wifi configuration --- src/freedombone-wifi | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/freedombone-wifi b/src/freedombone-wifi index 4feb0a12..8fe8b629 100755 --- a/src/freedombone-wifi +++ b/src/freedombone-wifi @@ -111,12 +111,12 @@ function hotspot_on { echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf if [ ! -f /etc/network/interfaces_original ]; then - if ! grep -q "# Hotspot" /etc/network/interfaces; then + if ! grep -q "# wifi enabled" /etc/network/interfaces; then cp /etc/network/interfaces /etc/network/interfaces_original fi fi - echo '# Hotspot' > /etc/network/interfaces + echo '# wifi enabled' > /etc/network/interfaces echo 'auto lo br0' >> /etc/network/interfaces echo 'iface lo inet loopback' >> /etc/network/interfaces echo '' >> /etc/network/interfaces @@ -139,11 +139,29 @@ function hotspot_on { function wifi_wpa2_psk { ssid=$1 passphrase=$2 - psk=$(wifi_get_psk "$ssid" "$passphrase") - echo "auto $WIFI_INTERFACE" > /etc/network/interfaces.d/wifi - echo "iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces.d/wifi - echo " wpa-ssid $ssid" >> /etc/network/interfaces.d/wifi - echo " wpa-psk $psk" >> /etc/network/interfaces.d/wifi + + if [ ! -f /etc/network/interfaces_original ]; then + if ! grep -q "# wifi enabled" /etc/network/interfaces; then + cp /etc/network/interfaces /etc/network/interfaces_original + fi + fi + + echo '# wifi enabled' > /etc/network/interfaces + echo 'auto lo' >> /etc/network/interfaces + echo 'iface lo inet loopback' >> /etc/network/interfaces + echo '' >> /etc/network/interfaces + echo 'allow-hotplug eth0' >> /etc/network/interfaces + echo 'iface eth0 inet dhcp' >> /etc/network/interfaces + echo '' >> /etc/network/interfaces + echo 'allow-hotplug wlan0' >> /etc/network/interfaces + echo 'iface wlan0 inet manual' >> /etc/network/interfaces + echo 'wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf' >> /etc/network/interfaces + echo '' >> /etc/network/interfaces + echo 'iface default inet dhcp' >> /etc/network/interfaces + + wpa_passphrase "$ssid" "$passphrase" > /etc/wpa_supplicant/wpa_supplicant.conf + + systemctl restart network-manager } function wifi_none {