From: Ted Lemon Date: Thu, 20 Nov 1997 04:37:04 +0000 (+0000) Subject: Check if variables have value before doing set $variable X-Git-Tag: DHCP-971122~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdaa711a9d91f69ab4a1c7c19b79e75fbe39d9f0;p=thirdparty%2Fdhcp.git Check if variables have value before doing set $variable --- diff --git a/client/scripts/freebsd b/client/scripts/freebsd index bb55953c4..dd49d8b17 100755 --- a/client/scripts/freebsd +++ b/client/scripts/freebsd @@ -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 diff --git a/client/scripts/netbsd b/client/scripts/netbsd index bb55953c4..dd49d8b17 100755 --- a/client/scripts/netbsd +++ b/client/scripts/netbsd @@ -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