2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-03 07:45:20 +00:00

Check if variables have value before doing set $variable

This commit is contained in:
Ted Lemon
1997-11-20 04:37:04 +00:00
parent c775ab0429
commit bdaa711a9d
2 changed files with 116 additions and 88 deletions

View File

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

View File

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