Adding casper 1.77+debian-4.
[live-boot-grml.git] / scripts / casper-bottom / 23networking
index f410321..2bdf9b0 100755 (executable)
@@ -22,9 +22,9 @@ esac
 log_begin_msg "$DESCRIPTION"
 
 if [ "${STATICIP}" == "frommedia" ] && [ -e  "$IFFILE" ] ; then
-       # will use existent /etc/network/interfaces
-       log_end_msg
-       exit 0
+    # will use existent /etc/network/interfaces
+    log_end_msg
+    exit 0
 fi
 
 cat > "$IFFILE" <<EOF
@@ -35,15 +35,14 @@ EOF
 
 udevtrigger
 
-if [ -z "${NETBOOT}" ] ; then
-       if [ ! -z "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]; then
-               parsed=$(echo "${STATICIP}" | sed -e 's/:/ /g')
-               for ifline in ${parsed}; do
-                       ifname="$(echo ${ifline} | cut -f1 -d ',')"
-                       ifaddress="$(echo ${ifline} | cut -f2 -d ',')"
-                       ifnetmask="$(echo ${ifline} | cut -f3 -d ',')"
-                       ifgateway="$(echo ${ifline} | cut -f4 -d ',')"
-                       cat >> "$IFFILE" <<EOF
+if [ -z "${NETBOOT}" -a -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]; then
+    parsed=$(echo "${STATICIP}" | sed -e 's/:/ /g')
+    for ifline in ${parsed}; do
+        ifname="$(echo ${ifline} | cut -f1 -d ',')"
+        ifaddress="$(echo ${ifline} | cut -f2 -d ',')"
+        ifnetmask="$(echo ${ifline} | cut -f3 -d ',')"
+        ifgateway="$(echo ${ifline} | cut -f4 -d ',')"
+        cat >> "$IFFILE" <<EOF
 auto ${ifname}
 iface ${ifname} inet static
     address ${ifaddress}
@@ -51,18 +50,27 @@ iface ${ifname} inet static
     gateway ${ifgateway}
 
 EOF
-               done
-       else
-               for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
-                       [ -e $interface ] || continue
-                       i="$(basename $interface)"
-                       cat >> "$IFFILE" <<EOF
-auto $i
-iface $i inet dhcp
+    done
+else
+    if [ -z "${NETBOOT}" ]; then
+        # default, dhcp assigned
+        method="dhcp"
+    else
+        # make sure that the preconfigured interface would not get reassigned by dhcp
+        # on startup by ifup script - otherwise our root fs might be disconnected!
+        method="manual"
+    fi
+
+    # iterate the physical interfaces and add them to the interfaces list
+    for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
+        [ -e $interface ] || continue
+        i="$(basename $interface)"
+        cat >> "$IFFILE" <<EOF
+auto ${i}
+iface ${i} inet ${method}
 
 EOF
-               done
-       fi
+    done
 fi
 
 log_end_msg