mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 14:25:41 +00:00
Check if variables have value before doing set $variable
This commit is contained in:
@@ -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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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,11 +73,13 @@ 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
|
||||||
set $new_static_routes
|
if [ "$new_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $new_static_routes
|
||||||
route add $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route add $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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
|
||||||
@@ -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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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,41 +129,44 @@ 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
|
||||||
set $new_routers
|
if [ "$new_routers" != "" ]; then
|
||||||
if ping -q -c 1 -w 1 $1; then
|
set $new_routers
|
||||||
if [ x$new_ip_address != x$alias_ip_address ] && \
|
if ping -q -c 1 -w 1 $1; then
|
||||||
|
if [ x$new_ip_address != x$alias_ip_address ] && \
|
||||||
[ x$alias_ip_address != x ]; then
|
[ x$alias_ip_address != x ]; then
|
||||||
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
|
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
|
||||||
route add $alias_ip_address 127.0.0.1
|
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
|
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
|
ifconfig $interface inet -alias $new_ip_address $medium
|
||||||
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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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
|
||||||
|
@@ -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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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,11 +73,13 @@ 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
|
||||||
set $new_static_routes
|
if [ "$new_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $new_static_routes
|
||||||
route add $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route add $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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
|
||||||
@@ -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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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,41 +129,44 @@ 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
|
||||||
set $new_routers
|
if [ "$new_routers" != "" ]; then
|
||||||
if ping -q -c 1 -w 1 $1; then
|
set $new_routers
|
||||||
if [ x$new_ip_address != x$alias_ip_address ] && \
|
if ping -q -c 1 -w 1 $1; then
|
||||||
|
if [ x$new_ip_address != x$alias_ip_address ] && \
|
||||||
[ x$alias_ip_address != x ]; then
|
[ x$alias_ip_address != x ]; then
|
||||||
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
|
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
|
||||||
route add $alias_ip_address 127.0.0.1
|
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
|
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
|
ifconfig $interface inet -alias $new_ip_address $medium
|
||||||
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
|
||||||
set $old_static_routes
|
if [ "$old_static_routes" != "" ]; then
|
||||||
while [ $# -gt 1 ]; do
|
set $old_static_routes
|
||||||
route delete $1 $2
|
while [ $# -gt 1 ]; do
|
||||||
shift; shift
|
route delete $1 $2
|
||||||
done
|
shift; shift
|
||||||
|
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
|
||||||
|
Reference in New Issue
Block a user