Parcourir la source

Make a guess at what the static IP should be

Bob Mottram il y a 8 ans
Parent
révision
d47b2b6b1c
1 fichiers modifiés avec 7 ajouts et 4 suppressions
  1. 7
    4
      src/freedombone-controlpanel

+ 7
- 4
src/freedombone-controlpanel Voir le fichier

@@ -1257,13 +1257,16 @@ function change_system_name {
1257 1257
 }
1258 1258
 
1259 1259
 function set_static_IP {
1260
-    STATIC_IP='192.168.1.60'
1261
-    STATIC_GATEWAY='192.168.1.1'
1260
+    IPv4_address=$(get_ipv4_address)
1261
+    IPv4_address_base=$(echo "$IPv4_address" | awk -F '.' '{print $1"."$2"."$3}')
1262
+    STATIC_IP="${IPv4_address_base}.60"
1263
+    STATIC_GATEWAY="${IPv4_address_base}.1"
1264
+
1262 1265
     NEW_STATIC_IP=
1263 1266
     NEW_STATIC_GATEWAY=
1264 1267
     if grep -q 'iface eth0 inet static' /etc/network/interfaces; then
1265
-        STATIC_IP=$(cat /etc/network/interfaces | grep "address " | awk -F ' ' '{print $2}' | head -n 1)
1266
-        STATIC_GATEWAY=$(cat /etc/network/interfaces | grep "gateway " | awk -F ' ' '{print $2}' | head -n 1)
1268
+        STATIC_IP=$(cat /etc/network/interfaces | grep "address " | head -n 1 | awk -F ' ' '{print $2}')
1269
+        STATIC_GATEWAY=$(cat /etc/network/interfaces | grep "gateway " | head -n 1 | awk -F ' ' '{print $2}')
1267 1270
     fi
1268 1271
 
1269 1272
     # get the IP for the box