]> git.ipfire.org Git - thirdparty/dhcp.git/blame - client/scripts/solaris
- Support for compressed 'domain name list' style DHCP option contents, and
[thirdparty/dhcp.git] / client / scripts / solaris
CommitLineData
ac867953
TL
1#!/bin/sh
2
8fddc394 3make_resolv_conf() {
dba5803b
DH
4 if [ x"$new_domain_name_servers" != x ]; then
5 cat /dev/null > /etc/resolv.conf.dhclient
6 if [ x"$new_domain_search" != x ]; then
7 echo search $new_domain_search >> /etc/resolv.conf.dhclient
8 elif [ x"$new_domain_name" != x ]; then
9 # Note that the DHCP 'Domain Name Option' is really just a domain
10 # name, and that this practice of using the domain name option as
11 # a search path is both nonstandard and deprecated.
12 echo search $new_domain_name >> /etc/resolv.conf.dhclient
13 fi
d758ad8c 14 for nameserver in $new_domain_name_servers; do
dba5803b 15 echo nameserver $nameserver >>/etc/resolv.conf.dhclient
d758ad8c 16 done
dba5803b
DH
17
18 mv /etc/resolv.conf.dhclient /etc/resolv.conf
d758ad8c 19 fi
8fddc394
TL
20}
21
22# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
23exit_with_hooks() {
24 exit_status=$1
06fa897b 25 if [ -f /etc/dhclient-exit-hooks ]; then
8fddc394
TL
26 . /etc/dhclient-exit-hooks
27 fi
28# probably should do something with exit status of the local script
29 exit $exit_status
30}
31
32# Invoke the local dhcp client enter hooks, if they exist.
06fa897b 33if [ -f /etc/dhclient-enter-hooks ]; then
8fddc394
TL
34 exit_status=0
35 . /etc/dhclient-enter-hooks
36 # allow the local script to abort processing of this state
37 # local script must set exit_status variable to nonzero.
38 if [ $exit_status -ne 0 ]; then
39 exit $exit_status
40 fi
41fi
42
ac867953
TL
43if [ x$new_broadcast_address != x ]; then
44 new_broadcast_arg="broadcast $new_broadcast_address"
45fi
46if [ x$old_broadcast_address != x ]; then
47 old_broadcast_arg="broadcast $old_broadcast_address"
48fi
49if [ x$new_subnet_mask != x ]; then
50 new_netmask_arg="netmask $new_subnet_mask"
51fi
52if [ x$old_subnet_mask != x ]; then
53 old_netmask_arg="netmask $old_subnet_mask"
54fi
55if [ x$alias_subnet_mask != x ]; then
56 alias_subnet_arg="netmask $alias_subnet_mask"
57fi
58
74f45f96
TL
59ifconfig=/sbin/ifconfig
60
61release=`uname -r`
62release=`expr $release : '\(.*\)\..*'`
63relmajor=`echo $release |sed -e 's/^\([^\.]*\)\..*$/\1/'`
64relminor=`echo $release |sed -e 's/^.*\.\([^\.]*\)$/\1/'`
ac867953
TL
65
66if [ x$reason = xMEDIUM ]; then
46b62638 67 eval "$ifconfig $interface $medium"
74f45f96 68 $ifconfig $interface
ac867953 69 sleep 1
8fddc394 70 exit_with_hooks 0
ac867953
TL
71fi
72
73if [ x$reason = xPREINIT ]; then
74 if [ x$alias_ip_address != x ]; then
74f45f96 75 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
ac867953
TL
76 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
77 fi
74f45f96
TL
78 if [ $relmajor -gt 5 ] || ( [ $relmajor -eq 5 ] && [ $relminor -ge 5 ] )
79 then
ac867953 80 # Turn the interface on
74f45f96
TL
81 $ifconfig $interface plumb
82 $ifconfig $interface up
ac867953 83 else
74f45f96 84 $ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
ac867953
TL
85 broadcast 255.255.255.255 up
86 fi
8fddc394 87 exit_with_hooks 0
ac867953
TL
88fi
89
90if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
8fddc394 91 exit_with_hooks 0;
ac867953
TL
92fi
93
94if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
95 [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
9f56e437
TL
96 current_hostname=`hostname`
97 if [ x$current_hostname = x ] || \
98 [ x$current_hostname = x$old_host_name ]; then
99 if [ x$current_hostname = x ] || \
100 [ x$new_host_name != x$old_host_name ]; then
101 hostname $new_host_name
102 fi
103 fi
104
ac867953
TL
105 if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
106 [ x$alias_ip_address != x$old_ip_address ]; then
74f45f96 107 $ifconfig ${interface}:1 inet 0 down > /dev/null 2>&1
ac867953
TL
108 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
109 fi
110 if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
74f45f96 111 $ifconfig ${interface} inet 0 down
ac867953
TL
112 route delete $old_ip_address 127.1 >/dev/null 2>&1
113 for router in $old_routers; do
114 route delete default $router >/dev/null 2>&1
115 done
ac867953
TL
116 fi
117 if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
118 [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
46b62638
TL
119 eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
120 $new_broadcast_arg $medium"
e43f1b77 121 route add $new_ip_address 127.1 1 >/dev/null 2>&1
ac867953 122 for router in $new_routers; do
e43f1b77 123 route add default $router 1 >/dev/null 2>&1
ac867953
TL
124 done
125 fi
126 if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
127 then
74f45f96
TL
128 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
129 route add $alias_ip_address 127.0.0.1 1
ac867953 130 fi
cad0776d 131 make_resolv_conf
8fddc394 132 exit_with_hooks 0
ac867953
TL
133fi
134
d758ad8c
TL
135if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
136 || [ x$reason = xSTOP ]; then
ac867953 137 if [ x$alias_ip_address != x ]; then
74f45f96 138 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
ac867953
TL
139 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
140 fi
141 if [ x$old_ip_address != x ]; then
74f45f96 142 $ifconfig $interface inet 0 down
ac867953
TL
143 route delete $old_ip_address 127.1 >/dev/null 2>&1
144 for router in $old_routers; do
145 route delete default $router >/dev/null 2>&1
146 done
ac867953
TL
147 fi
148 if [ x$alias_ip_address != x ]; then
74f45f96
TL
149 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
150 route add $alias_ip_address 127.0.0.1 1
ac867953 151 fi
8fddc394 152 exit_with_hooks 0
ac867953
TL
153fi
154
155if [ x$reason = xTIMEOUT ]; then
156 if [ x$alias_ip_address != x ]; then
74f45f96 157 $ifconfig ${interface}:1 0 down > /dev/null 2>&1
ac867953
TL
158 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
159 fi
46b62638
TL
160 eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
161 $new_broadcast_arg $medium"
ac867953
TL
162 sleep 1
163 set $new_routers
74f45f96 164 if ping -s -n -I 1 $1 64 1; then
ac867953
TL
165 if [ x$new_ip_address != x$alias_ip_address ] && \
166 [ x$alias_ip_address != x ]; then
74f45f96
TL
167 $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
168 route add $alias_ip_address 127.0.0.1 1
ac867953 169 fi
e43f1b77 170 route add $new_ip_address 127.1 1 >/dev/null 2>&1
ac867953 171 for router in $new_routers; do
e43f1b77 172 route add default $router 1 >/dev/null 2>&1
ac867953 173 done
cad0776d 174 make_resolv_conf
8fddc394 175 exit_with_hooks 0
ac867953 176 fi
74f45f96 177 $ifconfig $interface inet 0 down
ac867953
TL
178 for router in $old_routers; do
179 route delete default $router >/dev/null 2>&1
180 done
8fddc394 181 exit_with_hooks 1
ac867953
TL
182fi
183
8fddc394 184exit_with_hooks 0