瀏覽代碼

Setting static IP with wifi

Bob Mottram 8 年之前
父節點
當前提交
d32ada32b6
共有 2 個檔案被更改,包括 31 行新增7 行删除
  1. 18
    7
      src/freedombone-controlpanel
  2. 13
    0
      src/freedombone-utils-wifi

+ 18
- 7
src/freedombone-controlpanel 查看文件

@@ -1203,12 +1203,6 @@ function change_system_name {
1203 1203
 }
1204 1204
 
1205 1205
 function set_dynamic_IP {
1206
-    NETWORK_IS_STATIC=0
1207
-    read_config_param "NETWORK_IS_STATIC"
1208
-    if [ ${NETWORK_IS_STATIC} -eq 0 ]; then
1209
-        return
1210
-    fi
1211
-
1212 1206
     revert_to_dynamic=
1213 1207
     dialog --title $"Return to using a dynamic IP address" \
1214 1208
            --backtitle $"Freedombone Control Panel" \
@@ -1293,8 +1287,22 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_
1293 1287
 
1294 1288
             email_change_relay "$NEW_STATIC_IP"
1295 1289
 
1296
-            if [[ $(config_param_exists "WIFI_INTERFACE") == "0" ]]; then
1290
+            static_wifi_address=
1291
+            if [[ $(config_param_exists "WIFI_INTERFACE") == "1" ]]; then
1292
+                dialog --title $"Static local IP address" \
1293
+                       --backtitle $"Freedombone Control Panel" \
1294
+                       --yesno $"\nSet a static address for the wifi adapter?\n\nIf you select 'no' then wired ethernet will be used." 10 60
1295
+                sel=$?
1296
+                case $sel in
1297
+                    0) static_wifi_address=1
1298
+                       write_config_param "NETWORK_IS_STATIC" "1"
1299
+                       ;;
1300
+                esac
1301
+            fi
1302
+
1303
+            if [ ! $static_wifi_address ]; then
1297 1304
                 # wired network
1305
+                remove_wifi_startup_script
1298 1306
                 echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
1299 1307
                 echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
1300 1308
                 echo '' >> /etc/network/interfaces
@@ -1330,6 +1338,9 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_
1330 1338
                 echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
1331 1339
                 echo '#    network 192.168.7.0' >> /etc/network/interfaces
1332 1340
                 echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
1341
+            else
1342
+                # wifi network
1343
+                wifi_settings
1333 1344
             fi
1334 1345
 
1335 1346
             clear

+ 13
- 0
src/freedombone-utils-wifi 查看文件

@@ -573,6 +573,19 @@ function count_wlan {
573 573
     echo $ctr
574 574
 }
575 575
 
576
+function remove_wifi_startup_script {
577
+    remove_config_param "WIFI_INTERFACE"
578
+    systemd_file=/etc/systemd/system/wifistart.service
579
+    if [ -f $systemd_file ]; then
580
+        systemctl stop wifistart
581
+        systemctl disable wifistart
582
+        rm $systemd_file
583
+    fi
584
+    if [ -f $HOME/${PROJECT_NAME}-wifi.cfg ]; then
585
+        rm $HOME/${PROJECT_NAME}-wifi.cfg
586
+    fi
587
+}
588
+
576 589
 function create_wifi_startup_script {
577 590
     systemd_file=/etc/systemd/system/wifistart.service
578 591
     echo '[Unit]' > $systemd_file