Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / dhcp / client / scripts / solaris
blobe6187c7156d874cde8062c20a7ba61b0c078c807
1 #!/bin/sh
3 make_resolv_conf() {
4 if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
5 echo search $new_domain_name >/etc/resolv.conf
6 for nameserver in $new_domain_name_servers; do
7 echo nameserver $nameserver >>/etc/resolv.conf
8 done
9 fi
12 # Must be used on exit. Invokes the local dhcp client exit hooks, if any.
13 exit_with_hooks() {
14 exit_status=$1
15 if [ -f /etc/dhclient-exit-hooks ]; then
16 . /etc/dhclient-exit-hooks
18 # probably should do something with exit status of the local script
19 exit $exit_status
22 # Invoke the local dhcp client enter hooks, if they exist.
23 if [ -f /etc/dhclient-enter-hooks ]; then
24 exit_status=0
25 . /etc/dhclient-enter-hooks
26 # allow the local script to abort processing of this state
27 # local script must set exit_status variable to nonzero.
28 if [ $exit_status -ne 0 ]; then
29 exit $exit_status
33 if [ x$new_broadcast_address != x ]; then
34 new_broadcast_arg="broadcast $new_broadcast_address"
36 if [ x$old_broadcast_address != x ]; then
37 old_broadcast_arg="broadcast $old_broadcast_address"
39 if [ x$new_subnet_mask != x ]; then
40 new_netmask_arg="netmask $new_subnet_mask"
42 if [ x$old_subnet_mask != x ]; then
43 old_netmask_arg="netmask $old_subnet_mask"
45 if [ x$alias_subnet_mask != x ]; then
46 alias_subnet_arg="netmask $alias_subnet_mask"
49 ifconfig=/sbin/ifconfig
51 release=`uname -r`
52 release=`expr $release : '\(.*\)\..*'`
53 relmajor=`echo $release |sed -e 's/^\([^\.]*\)\..*$/\1/'`
54 relminor=`echo $release |sed -e 's/^.*\.\([^\.]*\)$/\1/'`
56 if [ x$reason = xMEDIUM ]; then
57 eval "$ifconfig $interface $medium"
58 $ifconfig $interface
59 sleep 1
60 exit_with_hooks 0
63 if [ x$reason = xPREINIT ]; then
64 if [ x$alias_ip_address != x ]; then
65 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
66 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
68 if [ $relmajor -gt 5 ] || ( [ $relmajor -eq 5 ] && [ $relminor -ge 5 ] )
69 then
70 # Turn the interface on
71 $ifconfig $interface plumb
72 $ifconfig $interface up
73 else
74 $ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
75 broadcast 255.255.255.255 up
76 fi
77 exit_with_hooks 0
80 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
81 exit_with_hooks 0;
84 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
85 [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
86 current_hostname=`hostname`
87 if [ x$current_hostname = x ] || \
88 [ x$current_hostname = x$old_host_name ]; then
89 if [ x$current_hostname = x ] || \
90 [ x$new_host_name != x$old_host_name ]; then
91 hostname $new_host_name
95 if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
96 [ x$alias_ip_address != x$old_ip_address ]; then
97 $ifconfig ${interface}:1 inet 0 down > /dev/null 2>&1
98 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
100 if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
101 $ifconfig ${interface} inet 0 down
102 route delete $old_ip_address 127.1 >/dev/null 2>&1
103 for router in $old_routers; do
104 route delete default $router >/dev/null 2>&1
105 done
107 if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
108 [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
109 eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
110 $new_broadcast_arg $medium"
111 route add $new_ip_address 127.1 1 >/dev/null 2>&1
112 for router in $new_routers; do
113 route add default $router 1 >/dev/null 2>&1
114 done
116 if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
117 then
118 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
119 route add $alias_ip_address 127.0.0.1 1
121 make_resolv_conf
122 exit_with_hooks 0
125 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
126 || [ x$reason = xSTOP ]; then
127 if [ x$alias_ip_address != x ]; then
128 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
129 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
131 if [ x$old_ip_address != x ]; then
132 $ifconfig $interface inet 0 down
133 route delete $old_ip_address 127.1 >/dev/null 2>&1
134 for router in $old_routers; do
135 route delete default $router >/dev/null 2>&1
136 done
138 if [ x$alias_ip_address != x ]; then
139 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
140 route add $alias_ip_address 127.0.0.1 1
142 exit_with_hooks 0
145 if [ x$reason = xTIMEOUT ]; then
146 if [ x$alias_ip_address != x ]; then
147 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
148 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
150 eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
151 $new_broadcast_arg $medium"
152 sleep 1
153 set $new_routers
154 if ping -s -n -I 1 $1 64 1; then
155 if [ x$new_ip_address != x$alias_ip_address ] && \
156 [ x$alias_ip_address != x ]; then
157 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
158 route add $alias_ip_address 127.0.0.1 1
160 route add $new_ip_address 127.1 1 >/dev/null 2>&1
161 for router in $new_routers; do
162 route add default $router 1 >/dev/null 2>&1
163 done
164 make_resolv_conf
165 exit_with_hooks 0
167 $ifconfig $interface inet 0 down
168 for router in $old_routers; do
169 route delete default $router >/dev/null 2>&1
170 done
171 exit_with_hooks 1
174 exit_with_hooks 0