Bob Mottram hace 9 años
padre
commit
d1ac3cddad
Se han modificado 2 ficheros con 40 adiciones y 17 borrados
  1. 26
    8
      src/freedombone-controlpanel
  2. 14
    9
      src/freedombone-wifi

+ 26
- 8
src/freedombone-controlpanel Ver fichero

@@ -1685,6 +1685,10 @@ Enter a static local IP address for this system.\n\nIt will typically be 192.168
1685 1685
 }
1686 1686
 
1687 1687
 function wifi_settings {
1688
+    if [ -f /etc/hostapd/hostapd.conf ]; then
1689
+        return
1690
+    fi
1691
+
1688 1692
     TEMP_WIFI_NETWORKS_FILE=~/.temp-${PROJECT_NAME}-wifi.cfg
1689 1693
     ${PROJECT_NAME}-wifi --networksinteractive $TEMP_WIFI_NETWORKS_FILE
1690 1694
     if [ -f $TEMP_WIFI_NETWORKS_FILE ]; then
@@ -1696,6 +1700,16 @@ function wifi_settings {
1696 1700
     fi
1697 1701
 }
1698 1702
 
1703
+function wifi_edit_networks {
1704
+    if [ -f /etc/hostapd/hostapd.conf ]; then
1705
+        return
1706
+    fi
1707
+    editor $WIFI_NETWORKS_FILE
1708
+    if [ -f $WIFI_NETWORKS_FILE ]; then
1709
+        ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
1710
+    fi
1711
+}
1712
+
1699 1713
 function hotspot_settings {
1700 1714
     data=$(tempfile 2>/dev/null)
1701 1715
     trap "rm -f $data" 0 1 2 5 15
@@ -1947,19 +1961,23 @@ function wifi_enable {
1947 1961
     ${PROJECT_NAME}-wifi --disable $disable_wifi
1948 1962
 }
1949 1963
 
1950
-function menu_wifi {
1951
-    hotspot_state=$'off'
1952
-    if [ -f /etc/hostapd/hostapd.conf ]; then
1953
-        hotspot_state=$'on'
1954
-    fi
1955
-    
1964
+function menu_wifi {    
1956 1965
     while true
1957 1966
     do
1967
+        status_str=$'Wifi OFF'
1968
+        if [ -f /etc/hostapd/hostapd.conf ]; then
1969
+            status_str=$'Hotspot ON'
1970
+        else
1971
+            if grep -q "# wifi enabled" /etc/network/interfaces; then
1972
+                status_str=$'Wifi ON'
1973
+            fi          
1974
+        fi
1975
+        
1958 1976
         data=$(tempfile 2>/dev/null)
1959 1977
         trap "rm -f $data" 0 1 2 5 15
1960 1978
         dialog --backtitle $"Freedombone Control Panel" \
1961 1979
                --title $"Wifi Menu" \
1962
-               --radiolist $"Choose an operation:" 13 70 5 \
1980
+               --radiolist $"${status_str}\n\nChoose an operation:" 14 70 6 \
1963 1981
                1 $"Enable or disable Wifi" off \
1964 1982
                2 $"Configure wifi networks" off \
1965 1983
                3 $"Manually edit wifi networks file" off \
@@ -1973,7 +1991,7 @@ function menu_wifi {
1973 1991
         case $(cat $data) in
1974 1992
             1) wifi_enable;;
1975 1993
             2) wifi_settings;;
1976
-            3) editor $WIFI_NETWORKS_FILE;;
1994
+            3) wifi_edit_networks;;
1977 1995
             4) hotspot_settings;;
1978 1996
             5) break;;
1979 1997
         esac

+ 14
- 9
src/freedombone-wifi Ver fichero

@@ -310,15 +310,15 @@ function create_networks_interactive {
310 310
 }
311 311
 
312 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
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
322 322
 }
323 323
 
324 324
 function show_help {
@@ -380,6 +380,11 @@ do
380 380
         --disable)
381 381
             shift
382 382
             WIFI_DISABLE=${1}
383
+            if [[ $WIFI_DISABLE == $'yes' || $WIFI_DISABLE == $'y' ]]; then
384
+                WIFI_DISABLE='yes'
385
+            else
386
+                WIFI_DISABLE='no'
387
+            fi          
383 388
             ;;
384 389
         *)
385 390
             # unknown option