bootdisk/trunk/batch-installer/installer-prep

hawk cvs at pld-linux.org
Sat Dec 3 20:04:38 CET 2005


Author: hawk
Date: Sat Dec  3 20:04:32 2005
New Revision: 6589

Modified:
   bootdisk/trunk/batch-installer/installer-prep
Log:
- if we are using dhcp, don't reconfigure network interface
  every time when installer-prep is executed


Modified: bootdisk/trunk/batch-installer/installer-prep
==============================================================================
--- bootdisk/trunk/batch-installer/installer-prep	(original)
+++ bootdisk/trunk/batch-installer/installer-prep	Sat Dec  3 20:04:32 2005
@@ -268,6 +268,9 @@
 
 # net config
 configure_network () {
+
+    local dhcp_pid
+
     if test "${net_v6}" != "yes" -a "${net_v6}" != "no" ; then
       if echo "${net_ipaddr}" | grep : ; then
         net_v6=yes
@@ -297,35 +300,41 @@
       log_wrap ip link set "$net_device" up
     fi
 
-    # remove any addresses assigned before (if any)
-    ip addr show "${net_device}" | grep "^ *inet " \
-    | while read inet addr rest; do
-      log debug "deleting existing address $addr for ${net_device}"
-      log_wrap ip addr delete $addr dev ${net_device}
-    done
+    # get pid of dhcp client
+    dhcp_pid=`ps|grep dhcpcd|awk '{print $1}'`
 
-    if test "${net_v6}" = "yes" ; then
-      ip addr show "${net_device}" | grep "^ *inet6 " \
+    # if we are using dhcp and dhcpcd is already running do nothing
+    if test "$net_ipaddr" = "dhcp" && test "$dhcp_pid" != ""; then
+      : skip
+    else
+      # remove any addresses assigned before (if any)
+      ip addr show "${net_device}" | grep "^ *inet " \
       | while read inet addr rest; do
-        if echo $addr | grep -q "^fe80" ; then
-	  continue
-	fi
-        log debug "deleting existing v6 address $addr for ${net_device}"
+        log debug "deleting existing address $addr for ${net_device}"
         log_wrap ip addr delete $addr dev ${net_device}
       done
+
+      if test "${net_v6}" = "yes" ; then
+        ip addr show "${net_device}" | grep "^ *inet6 " \
+        | while read inet addr rest; do
+          if echo $addr | grep -q "^fe80" ; then
+            continue
+          fi
+          log debug "deleting existing v6 address $addr for ${net_device}"
+          log_wrap ip addr delete $addr dev ${net_device}
+        done
+      fi
     fi
 
     if test "$net_ipaddr" = "dhcp"; then
-      # af_packet is needed for dhcpcd
-      load_module af_packet
-      # kill old instance of dhcpcd
-      kill `ps|grep dhcpcd|awk '{print $1}'` 2>/dev/null || :
-      rm /var/run/dhcp*pid 2>/dev/null || :
-      log info "waiting for dhcpcd to die (3 seconds)"
-      sleep 3
-      log info "running dhcpcd"
-      dhcpcd "$net_device" || die "Problems with dhcp"
-      log info "$net_device configured with dhcp"
+      # if dhcpcd is not running, run it
+      if test "$dhcp_pid" = ""; then
+        # af_packet is needed for dhcpcd
+        load_module af_packet
+        log info "running dhcpcd"
+        dhcpcd "$net_device" || die "Problems with dhcp"
+        log info "$net_device configured with dhcp"
+      fi
     else
       test "x$net_prefix" != "xauto" || guess_net_prefix
       log info "Setting address $net_ipaddr/$net_prefix for ${net_device}"



More information about the pld-cvs-commit mailing list