source: MondoRescue/branches/2.2.9/mindi-busybox/examples/var_service/dhcp_if/dhcp_handler@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/sh
2# executed by udhcpc
3# parameters: $1 and environment
4# $1 is:
5#
6# deconfig: udhcpc starts, or lease is lost.
7# Environment example: interface=eth0
8#
9# bound: lease is obtained. Environment example:
10# dhcptype=5
11# serverid=172.16.42.102
12# lease=97200
13# interface=eth0
14# ip=172.16.42.177
15# subnet=255.255.255.0
16# mask=24
17# broadcast=172.16.22.255
18# router=172.16.42.98
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
22#
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.
26#
27# nak: udhcpc received a NAK message.
28# Environment example: interface=eth0
29#
30# leasefail: udhcpc cannot obtain a lease (DHCP server not responding, etc).
31# Environment example: interface=eth0
32
33# TODO: put $domain into /etc/resolv.conf (thru /var/service/fw)
34
35service=${PWD##*/}
36file_ipconf="$service.ipconf"
37file_ntpconf="$service.ntpconf"
38dir_ipconf="/var/run/service/fw"
39dir_ntpconf="/var/run/service/ntp"
40
41exec >/dev/null
42#exec >>"$0.out" #debug
43exec 2>&1
44
45echo "`date`: Params: $*"
46
47if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
48 # Reconfigure network with this interface disabled
49 echo "Deconfiguring"
50 rm "$service.out"
51 rm "$file_ipconf"
52 rm "$file_ntpconf"
53 rm "$dir_ipconf/$file_ipconf"
54 rm "$dir_ntpconf/$file_ntpconf"
55 sv u /var/service/fw
56 exit
57fi
58
59# Bound: we've got the lease
60#env >"$service.out" # debug
61
62./convert2ipconf "$file_ipconf"
63# Reconfigure routing and firewall if needed
64diff --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/null 2>&1
65if test $? != 0; then
66 echo "Reconfiguring fw"
67 mkdir -p "$dir_ipconf" 2>/dev/null
68 cp "$file_ipconf" "$dir_ipconf/$file_ipconf"
69 sv u /var/service/fw
70fi
71
72if 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
76 if test $? != 0; then
77 echo "Reconfiguring ntp"
78 mkdir -p "$dir_ntpconf" 2>/dev/null
79 cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf"
80 sv t /var/service/ntp
81 sv u /var/service/ntp
82 fi
83fi
Note: See TracBrowser for help on using the repository browser.