Browse Source

Improve wifi configuration

Bob Mottram 9 years ago
parent
commit
266c31e10a
No account linked to committer's email
1 changed files with 25 additions and 7 deletions
  1. 25
    7
      src/freedombone-wifi

+ 25
- 7
src/freedombone-wifi View File

@@ -111,12 +111,12 @@ function hotspot_on {
111 111
     echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
112 112
 
113 113
     if [ ! -f /etc/network/interfaces_original ]; then
114
-        if ! grep -q "# Hotspot" /etc/network/interfaces; then
114
+        if ! grep -q "# wifi enabled" /etc/network/interfaces; then
115 115
             cp /etc/network/interfaces /etc/network/interfaces_original
116 116
         fi
117 117
     fi  
118 118
     
119
-    echo '# Hotspot' > /etc/network/interfaces
119
+    echo '# wifi enabled' > /etc/network/interfaces
120 120
     echo 'auto lo br0' >> /etc/network/interfaces
121 121
     echo 'iface lo inet loopback' >> /etc/network/interfaces
122 122
     echo '' >> /etc/network/interfaces
@@ -139,11 +139,29 @@ function hotspot_on {
139 139
 function wifi_wpa2_psk {
140 140
     ssid=$1
141 141
     passphrase=$2
142
-    psk=$(wifi_get_psk "$ssid" "$passphrase")
143
-    echo "auto $WIFI_INTERFACE" > /etc/network/interfaces.d/wifi
144
-    echo "iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces.d/wifi
145
-    echo "    wpa-ssid $ssid" >> /etc/network/interfaces.d/wifi
146
-    echo "    wpa-psk $psk" >> /etc/network/interfaces.d/wifi
142
+
143
+    if [ ! -f /etc/network/interfaces_original ]; then
144
+        if ! grep -q "# wifi enabled" /etc/network/interfaces; then
145
+            cp /etc/network/interfaces /etc/network/interfaces_original
146
+        fi
147
+    fi  
148
+    
149
+    echo '# wifi enabled' > /etc/network/interfaces
150
+    echo 'auto lo' >> /etc/network/interfaces
151
+    echo 'iface lo inet loopback' >> /etc/network/interfaces
152
+    echo '' >> /etc/network/interfaces
153
+    echo 'allow-hotplug eth0' >> /etc/network/interfaces
154
+    echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
155
+    echo '' >> /etc/network/interfaces
156
+    echo 'allow-hotplug wlan0' >> /etc/network/interfaces
157
+    echo 'iface wlan0 inet manual' >> /etc/network/interfaces
158
+    echo 'wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf' >> /etc/network/interfaces
159
+    echo '' >> /etc/network/interfaces
160
+    echo 'iface default inet dhcp' >> /etc/network/interfaces
161
+
162
+    wpa_passphrase "$ssid" "$passphrase" > /etc/wpa_supplicant/wpa_supplicant.conf
163
+
164
+    systemctl restart network-manager
147 165
 }
148 166
 
149 167
 function wifi_none {