Browse Source

Setting static IP with wifi

Bob Mottram 8 years ago
parent
commit
d32ada32b6
2 changed files with 31 additions and 7 deletions
  1. 18
    7
      src/freedombone-controlpanel
  2. 13
    0
      src/freedombone-utils-wifi

+ 18
- 7
src/freedombone-controlpanel View File

1203
 }
1203
 }
1204
 
1204
 
1205
 function set_dynamic_IP {
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
     revert_to_dynamic=
1206
     revert_to_dynamic=
1213
     dialog --title $"Return to using a dynamic IP address" \
1207
     dialog --title $"Return to using a dynamic IP address" \
1214
            --backtitle $"Freedombone Control Panel" \
1208
            --backtitle $"Freedombone Control Panel" \
1293
 
1287
 
1294
             email_change_relay "$NEW_STATIC_IP"
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
                 # wired network
1304
                 # wired network
1305
+                remove_wifi_startup_script
1298
                 echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
1306
                 echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
1299
                 echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
1307
                 echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
1300
                 echo '' >> /etc/network/interfaces
1308
                 echo '' >> /etc/network/interfaces
1330
                 echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
1338
                 echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
1331
                 echo '#    network 192.168.7.0' >> /etc/network/interfaces
1339
                 echo '#    network 192.168.7.0' >> /etc/network/interfaces
1332
                 echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
1340
                 echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
1341
+            else
1342
+                # wifi network
1343
+                wifi_settings
1333
             fi
1344
             fi
1334
 
1345
 
1335
             clear
1346
             clear

+ 13
- 0
src/freedombone-utils-wifi View File

573
     echo $ctr
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
 function create_wifi_startup_script {
589
 function create_wifi_startup_script {
577
     systemd_file=/etc/systemd/system/wifistart.service
590
     systemd_file=/etc/systemd/system/wifistart.service
578
     echo '[Unit]' > $systemd_file
591
     echo '[Unit]' > $systemd_file