3 # parameters: $1 and environment
6 # deconfig: udhcpc starts, or lease is lost.
7 # Environment example: interface=eth0
9 # bound: lease is obtained. Environment example:
11 # serverid=172.16.42.102
15 # subnet=255.255.255.0
17 # broadcast=172.16.22.255
19 # dns=10.34.32.125 10.32.63.5 10.34.255.7 10.11.255.27
20 # domain=lab.example.com example.com
21 # ntpsrv=10.34.32.125 10.34.255.7
23 # renew: lease is renewed. Environment is similar to "bound".
24 # The IP address does not change, however, the other DHCP paramaters,
25 # such as the default gateway, subnet mask, and dns server may change.
27 # nak: udhcpc received a NAK message.
28 # Environment example: interface=eth0
30 # leasefail: udhcpc cannot obtain a lease (DHCP server not responding, etc).
31 # Environment example: interface=eth0
33 # TODO: put $domain into /etc/resolv.conf (thru /var/service/fw)
36 file_ipconf="$service.ipconf"
37 file_ntpconf="$service.ntpconf"
38 dir_ipconf="/var/run/service/fw"
39 dir_ntpconf="/var/run/service/ntp"
42 #exec >>"$0.out" #debug
45 echo "`date`: Params: $*"
47 if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
48 # Reconfigure network with this interface disabled
53 rm "$dir_ipconf/$file_ipconf"
54 rm "$dir_ntpconf/$file_ntpconf"
59 # Bound: we've got the lease
60 #env >"$service.out" # debug
62 ./convert2ipconf "$file_ipconf"
63 # Reconfigure routing and firewall if needed
64 diff --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/null 2>&1
66 echo "Reconfiguring fw"
67 mkdir -p "$dir_ipconf" 2>/dev/null
68 cp "$file_ipconf" "$dir_ipconf/$file_ipconf"
72 if test -d /var/service/ntp; then
73 ./convert2ntpconf "$file_ntpconf"
74 # Reconfigure ntp server addresses if needed
75 diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1
77 echo "Reconfiguring ntp"
78 mkdir -p "$dir_ntpconf" 2>/dev/null
79 cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf"