Browse Source

Enabling or disabling wifi

Bob Mottram 9 years ago
parent
commit
e1a82b205f
No account linked to committer's email
2 changed files with 38 additions and 17 deletions
  1. 26
    9
      src/freedombone-controlpanel
  2. 12
    8
      src/freedombone-wifi

+ 26
- 9
src/freedombone-controlpanel View File

1932
     done
1932
     done
1933
 }
1933
 }
1934
 
1934
 
1935
+function wifi_enable {
1936
+    disable_wifi='yes'
1937
+    dialog --title $"Enable Wifi" \
1938
+           --backtitle $"Freedombone Control Panel" \
1939
+           --defaultno \
1940
+           --yesno $"\nDo you wish to enable wifi?" 10 50
1941
+    sel=$?
1942
+    case $sel in
1943
+        0) disable_wifi='no';;
1944
+        1) disable_wifi='yes';;
1945
+        255) return;;
1946
+    esac
1947
+    ${PROJECT_NAME}-wifi --disable $disable_wifi
1948
+}
1949
+
1935
 function menu_wifi {
1950
 function menu_wifi {
1936
     hotspot_state=$'off'
1951
     hotspot_state=$'off'
1937
     if [ -f /etc/hostapd/hostapd.conf ]; then
1952
     if [ -f /etc/hostapd/hostapd.conf ]; then
1944
         trap "rm -f $data" 0 1 2 5 15
1959
         trap "rm -f $data" 0 1 2 5 15
1945
         dialog --backtitle $"Freedombone Control Panel" \
1960
         dialog --backtitle $"Freedombone Control Panel" \
1946
                --title $"Wifi Menu" \
1961
                --title $"Wifi Menu" \
1947
-               --radiolist $"Choose an operation:" 12 70 4 \
1948
-               1 $"Configure wifi networks" off \
1949
-               2 $"Manually edit wifi networks file" off \
1950
-               3 $"Hotspot settings" off \
1951
-               4 $"Exit" on 2> $data
1962
+               --radiolist $"Choose an operation:" 13 70 5 \
1963
+               1 $"Enable or disable Wifi" off \
1964
+               2 $"Configure wifi networks" off \
1965
+               3 $"Manually edit wifi networks file" off \
1966
+               4 $"Hotspot settings" off \
1967
+               5 $"Exit" on 2> $data
1952
         sel=$?
1968
         sel=$?
1953
         case $sel in
1969
         case $sel in
1954
             1) break;;
1970
             1) break;;
1955
             255) break;;
1971
             255) break;;
1956
         esac
1972
         esac
1957
         case $(cat $data) in
1973
         case $(cat $data) in
1958
-            1) wifi_settings;;
1959
-            2) editor $WIFI_NETWORKS_FILE;;
1960
-            3) hotspot_settings;;
1961
-            4) break;;
1974
+            1) wifi_enable;;
1975
+            2) wifi_settings;;
1976
+            3) editor $WIFI_NETWORKS_FILE;;
1977
+            4) hotspot_settings;;
1978
+            5) break;;
1962
         esac
1979
         esac
1963
     done
1980
     done
1964
 }
1981
 }

+ 12
- 8
src/freedombone-wifi View File

309
     done
309
     done
310
 }
310
 }
311
 
311
 
312
-function disable {
313
-    hotspot_off
314
-    echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
315
-    echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
316
-    echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
317
-    systemctl restart network-manager
312
+function disable_wifi {
313
+	if [[ ${1} == 'yes' || ${1} == 'y' ]]; then
314
+		hotspot_off
315
+		echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
316
+		echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
317
+		echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
318
+		systemctl restart network-manager
319
+	else
320
+		networks_from_file
321
+	fi
318
 }
322
 }
319
 
323
 
320
 function show_help {
324
 function show_help {
384
     shift
388
     shift
385
 done
389
 done
386
 
390
 
387
-if [[ $WIFI_DISABLE == $'yes' || $WIFI_DISABLE == $'y' ]]; then
388
-    disable
391
+if [ $WIFI_DISABLE ]; then
392
+    disable_wifi $WIFI_DISABLE
389
     exit 0
393
     exit 0
390
 fi
394
 fi
391
 
395