diff options
Diffstat (limited to 'client/scripts/freebsd')
-rwxr-xr-x | client/scripts/freebsd | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/client/scripts/freebsd b/client/scripts/freebsd index 61937321..2f0623ef 100755 --- a/client/scripts/freebsd +++ b/client/scripts/freebsd @@ -1,4 +1,8 @@ #!/bin/sh +# +# $Id: freebsd,v 1.16 2005/03/17 20:14:56 dhankins Exp $ +# +# $FreeBSD$ if [ -x /usr/bin/logger ]; then LOGGER="/usr/bin/logger -s -p user.notice -t dhclient" @@ -9,13 +13,24 @@ fi make_resolv_conf() { if [ x"$new_domain_name_servers" != x ]; then if [ "x$new_domain_name" != x ]; then - echo search $new_domain_name >/etc/resolv.conf + ( echo search $new_domain_name >/etc/resolv.conf ) + exit_status=$? else - rm /etc/resolv.conf + if [ -e /etc/resolv.conf ] ; then + ( rm /etc/resolv.conf ) + exit_status=$? + else + ( touch /etc/resolv.conf ) + exit_status=$? + fi + fi + if [ $exit_status -ne 0 ]; then + $LOGGER "WARNING: Unable to update resolv.conf: Error $exit_status" + else + for nameserver in $new_domain_name_servers; do + ( echo nameserver $nameserver >>/etc/resolv.conf ) + done fi - for nameserver in $new_domain_name_servers; do - echo nameserver $nameserver >>/etc/resolv.conf - done fi } @@ -84,7 +99,7 @@ fi if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then - current_hostname=`hostname` + current_hostname=`/bin/hostname` if [ x$current_hostname = x ] || \ [ x$current_hostname = x$old_host_name ]; then if [ x$current_hostname = x ] || \ @@ -105,7 +120,7 @@ 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 + if [ -n "$old_static_routes" ]; then set -- $old_static_routes while [ $# -gt 1 ]; do route delete $1 $2 @@ -118,17 +133,17 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \ $new_broadcast_arg $medium" - $LOGGER "New IP Address($interface): $new_ip_address" - $LOGGER "New Subnet Mask($interface): $new_subnet_mask" - $LOGGER "New Broadcast Address($interface): $new_broadcast_address" - if [ "$new_routers" != "" ]; then + $LOGGER "New IP Address ($interface): $new_ip_address" + $LOGGER "New Subnet Mask ($interface): $new_subnet_mask" + $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" + if [ -n "$new_routers" ]; then $LOGGER "New Routers: $new_routers" 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 - if [ "$new_static_routes" != "" ]; then + if [ -n "$new_static_routes" ]; then $LOGGER "New Static Routes: $new_static_routes" set -- $new_static_routes while [ $# -gt 1 ]; do @@ -158,14 +173,14 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ for router in $old_routers; do route delete default $router >/dev/null 2>&1 done - if [ "$old_static_routes" != "" ]; then + if [ -n "$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' \ + arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \ |sh >/dev/null 2>&1 fi if [ x$alias_ip_address != x ]; then @@ -182,11 +197,11 @@ if [ x$reason = xTIMEOUT ]; then fi eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \ $new_broadcast_arg $medium" - $LOGGER "New IP Address($interface): $new_ip_address" - $LOGGER "New Subnet Mask($interface): $new_subnet_mask" - $LOGGER "New Broadcast Address($interface): $new_broadcast_address" + $LOGGER "New IP Address ($interface): $new_ip_address" + $LOGGER "New Subnet Mask ($interface): $new_subnet_mask" + $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" sleep 1 - if [ "$new_routers" != "" ]; then + if [ -n "$new_routers" ]; then $LOGGER "New Routers: $new_routers" set -- $new_routers if ping -q -c 1 $1; then @@ -212,7 +227,7 @@ 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 + if [ -n "$old_static_routes" ]; then set -- $old_static_routes while [ $# -gt 1 ]; do route delete $1 $2 |