]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Check if variables have value before doing set $variable
authorTed Lemon <source@isc.org>
Thu, 20 Nov 1997 04:37:04 +0000 (04:37 +0000)
committerTed Lemon <source@isc.org>
Thu, 20 Nov 1997 04:37:04 +0000 (04:37 +0000)
client/scripts/freebsd
client/scripts/netbsd

index bb55953c4feb88b46636cee0f4f4038912ed727d..dd49d8b179e5751238d1e7a3e911dc82a64a8ce1 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/sh
 
+if [ x$new_network_number != x ]; then
+   echo New Network Number: $new_network_number
+fi
+
 if [ x$new_broadcast_address != x ]; then
+ echo New Broadcast Address: $new_broadcast_address
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
 if [ x$old_broadcast_address != x ]; then
@@ -51,11 +56,13 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    set $old_static_routes
-    while [ $# -gt 1 ]; do
-      route delete $1 $2
-      shift; shift
-    done
+    if [ "$old_static_routes" != "" ]; then
+      set $old_static_routes
+      while [ $# -gt 1 ]; do
+       route delete $1 $2
+       shift; shift
+      done
+    fi
     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
@@ -66,11 +73,13 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     for router in $new_routers; do
       route add default $router >/dev/null 2>&1
     done
-    set $new_static_routes
-    while [ $# -gt 1 ]; do
-      route add $1 $2
-      shift; shift
-    done
+    if [ "$new_static_routes" != "" ]; then
+      set $new_static_routes
+      while [ $# -gt 1 ]; do
+       route add $1 $2
+       shift; shift
+      done
+    fi
   fi
   if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
    then
@@ -95,11 +104,13 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    set $old_static_routes
-    while [ $# -gt 1 ]; do
-      route delete $1 $2
-      shift; shift
-    done
+    if [ "$old_static_routes" != "" ]; then
+      set $old_static_routes
+      while [ $# -gt 1 ]; do
+       route delete $1 $2
+       shift; shift
+      done
+    fi
     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                |sh >/dev/null 2>&1
   fi
@@ -118,41 +129,44 @@ if [ x$reason = xTIMEOUT ]; then
   ifconfig $interface inet $new_ip_address $new_netmask_arg \
                                        $new_broadcast_arg $medium
   sleep 1
-  set $new_routers
-  if ping -q -c 1 -w 1 $1; then
-    if [ x$new_ip_address != x$alias_ip_address ] && \
+  if [ "$new_routers" != "" ]; then
+    set $new_routers
+    if ping -q -c 1 -w 1 $1; then
+      if [ x$new_ip_address != x$alias_ip_address ] && \
                        [ x$alias_ip_address != x ]; then
-      ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
-      route add $alias_ip_address 127.0.0.1
+       ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
+       route add $alias_ip_address 127.0.0.1
+      fi
+      route add $new_ip_address 127.1 >/dev/null 2>&1
+      for router in $new_routers; do
+       route add default $router >/dev/null 2>&1
+      done
+      set $new_static_routes
+      while [ $# -gt 1 ]; do
+       route add $0 $1
+       shift; shift
+      done
+      echo search $new_domain_name >/etc/resolv.conf.std
+      for nameserver in $new_domain_name_servers; do
+       echo nameserver $nameserver >>/etc/resolv.conf.std
+      done
+      if [ -f /etc/resolv.conf ]; then
+       rm -f /etc/resolv.conf
+      fi
+      mv /etc/resolv.conf.std /etc/resolv.conf
+      exit 0
     fi
-    route add $new_ip_address 127.1 >/dev/null 2>&1
-    for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
-    done
-    set $new_static_routes
-    while [ $# -gt 1 ]; do
-      route add $0 $1
-      shift; shift
-    done
-    echo search $new_domain_name >/etc/resolv.conf.std
-    for nameserver in $new_domain_name_servers; do
-      echo nameserver $nameserver >>/etc/resolv.conf.std
-    done
-    if [ -f /etc/resolv.conf ]; then
-      rm -f /etc/resolv.conf
-    fi
-    mv /etc/resolv.conf.std /etc/resolv.conf
-    exit 0
-  fi
   ifconfig $interface inet -alias $new_ip_address $medium
   for router in $old_routers; do
     route delete default $router >/dev/null 2>&1
   done
-  set $old_static_routes
-  while [ $# -gt 1 ]; do
-    route delete $1 $2
-    shift; shift
-  done
+  if [ "$old_static_routes" != "" ]; then
+    set $old_static_routes
+    while [ $# -gt 1 ]; do
+      route delete $1 $2
+      shift; shift
+    done
+  fi
   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                        |sh >/dev/null 2>&1
   exit 1
index bb55953c4feb88b46636cee0f4f4038912ed727d..dd49d8b179e5751238d1e7a3e911dc82a64a8ce1 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/sh
 
+if [ x$new_network_number != x ]; then
+   echo New Network Number: $new_network_number
+fi
+
 if [ x$new_broadcast_address != x ]; then
+ echo New Broadcast Address: $new_broadcast_address
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
 if [ x$old_broadcast_address != x ]; then
@@ -51,11 +56,13 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    set $old_static_routes
-    while [ $# -gt 1 ]; do
-      route delete $1 $2
-      shift; shift
-    done
+    if [ "$old_static_routes" != "" ]; then
+      set $old_static_routes
+      while [ $# -gt 1 ]; do
+       route delete $1 $2
+       shift; shift
+      done
+    fi
     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
@@ -66,11 +73,13 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
     for router in $new_routers; do
       route add default $router >/dev/null 2>&1
     done
-    set $new_static_routes
-    while [ $# -gt 1 ]; do
-      route add $1 $2
-      shift; shift
-    done
+    if [ "$new_static_routes" != "" ]; then
+      set $new_static_routes
+      while [ $# -gt 1 ]; do
+       route add $1 $2
+       shift; shift
+      done
+    fi
   fi
   if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
    then
@@ -95,11 +104,13 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
-    set $old_static_routes
-    while [ $# -gt 1 ]; do
-      route delete $1 $2
-      shift; shift
-    done
+    if [ "$old_static_routes" != "" ]; then
+      set $old_static_routes
+      while [ $# -gt 1 ]; do
+       route delete $1 $2
+       shift; shift
+      done
+    fi
     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                |sh >/dev/null 2>&1
   fi
@@ -118,41 +129,44 @@ if [ x$reason = xTIMEOUT ]; then
   ifconfig $interface inet $new_ip_address $new_netmask_arg \
                                        $new_broadcast_arg $medium
   sleep 1
-  set $new_routers
-  if ping -q -c 1 -w 1 $1; then
-    if [ x$new_ip_address != x$alias_ip_address ] && \
+  if [ "$new_routers" != "" ]; then
+    set $new_routers
+    if ping -q -c 1 -w 1 $1; then
+      if [ x$new_ip_address != x$alias_ip_address ] && \
                        [ x$alias_ip_address != x ]; then
-      ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
-      route add $alias_ip_address 127.0.0.1
+       ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
+       route add $alias_ip_address 127.0.0.1
+      fi
+      route add $new_ip_address 127.1 >/dev/null 2>&1
+      for router in $new_routers; do
+       route add default $router >/dev/null 2>&1
+      done
+      set $new_static_routes
+      while [ $# -gt 1 ]; do
+       route add $0 $1
+       shift; shift
+      done
+      echo search $new_domain_name >/etc/resolv.conf.std
+      for nameserver in $new_domain_name_servers; do
+       echo nameserver $nameserver >>/etc/resolv.conf.std
+      done
+      if [ -f /etc/resolv.conf ]; then
+       rm -f /etc/resolv.conf
+      fi
+      mv /etc/resolv.conf.std /etc/resolv.conf
+      exit 0
     fi
-    route add $new_ip_address 127.1 >/dev/null 2>&1
-    for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
-    done
-    set $new_static_routes
-    while [ $# -gt 1 ]; do
-      route add $0 $1
-      shift; shift
-    done
-    echo search $new_domain_name >/etc/resolv.conf.std
-    for nameserver in $new_domain_name_servers; do
-      echo nameserver $nameserver >>/etc/resolv.conf.std
-    done
-    if [ -f /etc/resolv.conf ]; then
-      rm -f /etc/resolv.conf
-    fi
-    mv /etc/resolv.conf.std /etc/resolv.conf
-    exit 0
-  fi
   ifconfig $interface inet -alias $new_ip_address $medium
   for router in $old_routers; do
     route delete default $router >/dev/null 2>&1
   done
-  set $old_static_routes
-  while [ $# -gt 1 ]; do
-    route delete $1 $2
-    shift; shift
-  done
+  if [ "$old_static_routes" != "" ]; then
+    set $old_static_routes
+    while [ $# -gt 1 ]; do
+      route delete $1 $2
+      shift; shift
+    done
+  fi
   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
                                                        |sh >/dev/null 2>&1
   exit 1