2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 22:35:25 +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
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
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,12 +73,14 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
for router in $new_routers; do
route add default $router >/dev/null 2>&1
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
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
route delete default $router >/dev/null 2>&1
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,6 +129,7 @@ if [ x$reason = xTIMEOUT ]; then
ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $medium
sleep 1
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 ] && \
@@ -148,11 +160,13 @@ if [ x$reason = xTIMEOUT ]; then
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
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

View File

@@ -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
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,12 +73,14 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
for router in $new_routers; do
route add default $router >/dev/null 2>&1
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
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
route delete default $router >/dev/null 2>&1
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,6 +129,7 @@ if [ x$reason = xTIMEOUT ]; then
ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $medium
sleep 1
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 ] && \
@@ -148,11 +160,13 @@ if [ x$reason = xTIMEOUT ]; then
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
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