Bob Mottram před 9 roky
rodič
revize
d1ac3cddad
2 změnil soubory, kde provedl 40 přidání a 17 odebrání
  1. 26
    8
      src/freedombone-controlpanel
  2. 14
    9
      src/freedombone-wifi

+ 26
- 8
src/freedombone-controlpanel Zobrazit soubor

1685
 }
1685
 }
1686
 
1686
 
1687
 function wifi_settings {
1687
 function wifi_settings {
1688
+    if [ -f /etc/hostapd/hostapd.conf ]; then
1689
+        return
1690
+    fi
1691
+
1688
     TEMP_WIFI_NETWORKS_FILE=~/.temp-${PROJECT_NAME}-wifi.cfg
1692
     TEMP_WIFI_NETWORKS_FILE=~/.temp-${PROJECT_NAME}-wifi.cfg
1689
     ${PROJECT_NAME}-wifi --networksinteractive $TEMP_WIFI_NETWORKS_FILE
1693
     ${PROJECT_NAME}-wifi --networksinteractive $TEMP_WIFI_NETWORKS_FILE
1690
     if [ -f $TEMP_WIFI_NETWORKS_FILE ]; then
1694
     if [ -f $TEMP_WIFI_NETWORKS_FILE ]; then
1696
     fi
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
 function hotspot_settings {
1713
 function hotspot_settings {
1700
     data=$(tempfile 2>/dev/null)
1714
     data=$(tempfile 2>/dev/null)
1701
     trap "rm -f $data" 0 1 2 5 15
1715
     trap "rm -f $data" 0 1 2 5 15
1947
     ${PROJECT_NAME}-wifi --disable $disable_wifi
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
     while true
1965
     while true
1957
     do
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
         data=$(tempfile 2>/dev/null)
1976
         data=$(tempfile 2>/dev/null)
1959
         trap "rm -f $data" 0 1 2 5 15
1977
         trap "rm -f $data" 0 1 2 5 15
1960
         dialog --backtitle $"Freedombone Control Panel" \
1978
         dialog --backtitle $"Freedombone Control Panel" \
1961
                --title $"Wifi Menu" \
1979
                --title $"Wifi Menu" \
1962
-               --radiolist $"Choose an operation:" 13 70 5 \
1980
+               --radiolist $"${status_str}\n\nChoose an operation:" 14 70 6 \
1963
                1 $"Enable or disable Wifi" off \
1981
                1 $"Enable or disable Wifi" off \
1964
                2 $"Configure wifi networks" off \
1982
                2 $"Configure wifi networks" off \
1965
                3 $"Manually edit wifi networks file" off \
1983
                3 $"Manually edit wifi networks file" off \
1973
         case $(cat $data) in
1991
         case $(cat $data) in
1974
             1) wifi_enable;;
1992
             1) wifi_enable;;
1975
             2) wifi_settings;;
1993
             2) wifi_settings;;
1976
-            3) editor $WIFI_NETWORKS_FILE;;
1994
+            3) wifi_edit_networks;;
1977
             4) hotspot_settings;;
1995
             4) hotspot_settings;;
1978
             5) break;;
1996
             5) break;;
1979
         esac
1997
         esac

+ 14
- 9
src/freedombone-wifi Zobrazit soubor

310
 }
310
 }
311
 
311
 
312
 function disable_wifi {
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
 function show_help {
324
 function show_help {
380
         --disable)
380
         --disable)
381
             shift
381
             shift
382
             WIFI_DISABLE=${1}
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
             # unknown option
390
             # unknown option