Bladeren bron

Configure eth0 within images

Bob Mottram 7 jaren geleden
bovenliggende
commit
9c60ac9110
1 gewijzigde bestanden met toevoegingen van 12 en 8 verwijderingen
  1. 12
    8
      src/freedombone-image-customise

+ 12
- 8
src/freedombone-image-customise Bestand weergeven

@@ -203,16 +203,17 @@ configure_networking() {
203 203
         return
204 204
     fi
205 205
 
206
+    { echo '# This file describes the network interfaces available on your system';
207
+      echo '# and how to activate them. For more information, see interfaces(5).';
208
+      echo 'source /etc/network/interfaces.d/*'; } > "$rootdir/etc/network/interfaces"
209
+
206 210
     if [[ "$GENERIC_IMAGE" == "no" ]]; then
207
-        echo '# This file describes the network interfaces available on your system' > "$rootdir/etc/network/interfaces"
208
-        echo '# and how to activate them. For more information, see interfaces(5).' >> "$rootdir/etc/network/interfaces"
209
-        echo 'source /etc/network/interfaces.d/*' >> "$rootdir/etc/network/interfaces"
210 211
 
211
-        echo "auto eth0
212
-iface eth0 inet static
213
-    address $BOX_IP_ADDRESS
214
-    netmask 255.255.255.0
215
-    gateway $ROUTER_IP_ADDRESS" > "$rootdir/etc/network/interfaces.d/static"
212
+        { echo 'auto eth0';
213
+          echo 'iface eth0 inet static';
214
+          echo "address $BOX_IP_ADDRESS";
215
+          echo 'netmask 255.255.255.0';
216
+          echo "gateway $ROUTER_IP_ADDRESS"; } > "$rootdir/etc/network/interfaces.d/static"
216 217
 
217 218
         hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
218 219
         a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
@@ -221,6 +222,9 @@ iface eth0 inet static
221 222
         d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
222 223
         e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
223 224
         echo "hwaddress ether de:$a:$b:$c:$d:$e" > "$rootdir/etc/network/interfaces.d/macaddress"
225
+    else
226
+        { echo 'auto eth0';
227
+          echo 'iface eth0 inet dhcp'; } > "$rootdir/etc/network/interfaces.d/dynamic"
224 228
     fi
225 229
 
226 230
     # configure DNS