diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-09 11:04:54 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-09 11:04:54 +0100 |
commit | 002bdc3e2af27279323d900e5a74607d42724c62 (patch) | |
tree | 26c8e2709f74398080a37ca19d0bb0d5641d180a | |
parent | 391dd92ce218dea9a015e6b06f95403772876ac9 (diff) | |
download | busybox-w32-002bdc3e2af27279323d900e5a74607d42724c62.tar.gz busybox-w32-002bdc3e2af27279323d900e5a74607d42724c62.tar.bz2 busybox-w32-002bdc3e2af27279323d900e5a74607d42724c62.zip |
tweak service examples a bit (less verbose comment in dhcp_if)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-x | examples/var_service/dhcp_if/dhcp_handler | 62 | ||||
-rwxr-xr-x | examples/var_service/ifplugd_if/run | 9 |
2 files changed, 34 insertions, 37 deletions
diff --git a/examples/var_service/dhcp_if/dhcp_handler b/examples/var_service/dhcp_if/dhcp_handler index a119b4db1..51740406b 100755 --- a/examples/var_service/dhcp_if/dhcp_handler +++ b/examples/var_service/dhcp_if/dhcp_handler | |||
@@ -1,31 +1,12 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # executed by udhcpc | 2 | # executed by udhcpc |
3 | # parameters: $1 and environment | 3 | # parameters: $1 and environment |
4 | # | ||
5 | # $1 is: | 4 | # $1 is: |
6 | # deconfig: This argument is used when udhcpc starts, and | ||
7 | # when a leases is lost. The script should put the interface in an | ||
8 | # up, but deconfigured state, ie: ifconfig $interface 0.0.0.0. | ||
9 | # | ||
10 | # bound: This argument is used when udhcpc moves from an | ||
11 | # unbound, to a bound state. All of the paramaters are set in | ||
12 | # enviromental variables, The script should configure the interface, | ||
13 | # and set any other relavent parameters (default gateway, dns server, | ||
14 | # etc). | ||
15 | # | ||
16 | # renew: This argument is used when a DHCP lease is renewed. All of | ||
17 | # the paramaters are set in enviromental variables. This argument is | ||
18 | # used when the interface is already configured, so the IP address, | ||
19 | # will not change, however, the other DHCP paramaters, such as the | ||
20 | # default gateway, subnet mask, and dns server may change. | ||
21 | # | 5 | # |
22 | # nak: This argument is used with udhcpc receives a NAK message. | 6 | # deconfig: udhcpc starts, or lease is lost. |
23 | # The script with the deconfig argument will be called directly | 7 | # Environment example: interface=eth0 |
24 | # afterwards, so no changes to the network interface are neccessary. | ||
25 | # This hook is provided for purely informational purposes (the | ||
26 | # message option may contain a reason for the NAK). | ||
27 | # | 8 | # |
28 | # env shows something like: | 9 | # bound: lease is obtained. Environment example: |
29 | # dhcptype=5 | 10 | # dhcptype=5 |
30 | # serverid=172.16.42.102 | 11 | # serverid=172.16.42.102 |
31 | # lease=97200 | 12 | # lease=97200 |
@@ -38,9 +19,18 @@ | |||
38 | # dns=10.34.32.125 10.32.63.5 10.34.255.7 10.11.255.27 | 19 | # dns=10.34.32.125 10.32.63.5 10.34.255.7 10.11.255.27 |
39 | # domain=lab.example.com example.com | 20 | # domain=lab.example.com example.com |
40 | # ntpsrv=10.34.32.125 10.34.255.7 | 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 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 | ||
41 | 32 | ||
42 | # TODO: put domain into /etc/resolv.conf (thru /var/service/fw) | 33 | # TODO: put $domain into /etc/resolv.conf (thru /var/service/fw) |
43 | # TODO: feed ntp IPs to /var/service/ntp | ||
44 | 34 | ||
45 | service=${PWD##*/} | 35 | service=${PWD##*/} |
46 | file_ipconf="$service.ipconf" | 36 | file_ipconf="$service.ipconf" |
@@ -69,23 +59,25 @@ fi | |||
69 | # Bound: we've got the lease | 59 | # Bound: we've got the lease |
70 | #env >"$service.out" # debug | 60 | #env >"$service.out" # debug |
71 | 61 | ||
72 | ./convert2ipconf "$file_ipconf" | 62 | ./convert2ipconf "$file_ipconf" |
73 | # Reconfigure routing and firewall if needed | 63 | # Reconfigure routing and firewall if needed |
74 | diff --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/null 2>&1 | 64 | diff --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/null 2>&1 |
75 | if test "$?" != "0"; then | 65 | if test $? != 0; then |
76 | echo "Reconfiguring fw" | 66 | echo "Reconfiguring fw" |
77 | mkdir -p "$dir_ipconf" 2>/dev/null | 67 | mkdir -p "$dir_ipconf" 2>/dev/null |
78 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" | 68 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" |
79 | sv u /var/service/fw | 69 | sv u /var/service/fw |
80 | fi | 70 | fi |
81 | 71 | ||
82 | ./convert2ntpconf "$file_ntpconf" | 72 | if test -d /var/service/ntp; then |
83 | # Reconfigure ntp server addresses if needed | 73 | ./convert2ntpconf "$file_ntpconf" |
84 | diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1 | 74 | # Reconfigure ntp server addresses if needed |
85 | if test "$?" != "0"; then | 75 | diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1 |
86 | echo "Reconfiguring ntp" | 76 | if test $? != 0; then |
87 | mkdir -p "$dir_ntpconf" 2>/dev/null | 77 | echo "Reconfiguring ntp" |
88 | cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" | 78 | mkdir -p "$dir_ntpconf" 2>/dev/null |
89 | sv t /var/service/ntp | 79 | cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" |
90 | sv u /var/service/ntp | 80 | sv t /var/service/ntp |
81 | sv u /var/service/ntp | ||
82 | fi | ||
91 | fi | 83 | fi |
diff --git a/examples/var_service/ifplugd_if/run b/examples/var_service/ifplugd_if/run index 360b75a3f..2781cf9f9 100755 --- a/examples/var_service/ifplugd_if/run +++ b/examples/var_service/ifplugd_if/run | |||
@@ -1,5 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | #exec >/dev/null | ||
3 | exec 2>&1 | 4 | exec 2>&1 |
4 | exec </dev/null | 5 | exec </dev/null |
5 | 6 | ||
@@ -12,9 +13,13 @@ exec \ | |||
12 | env - PATH="$PATH" \ | 13 | env - PATH="$PATH" \ |
13 | softlimit \ | 14 | softlimit \ |
14 | setuidgid root \ | 15 | setuidgid root \ |
15 | ifplugd -apqns -t3 -u9 -d9 -i "$if" -r "$pwd/ifplugd_handler" | 16 | ifplugd -apqns -t3 -u8 -d8 -i "$if" -r "$pwd/ifplugd_handler" |
16 | 17 | ||
17 | # we use -t3 to wake ifplugd up less often | 18 | # We use -t3 to wake ifplugd up less often. |
19 | # If after three tests (3*3=9 > 8) link state seen to be different, | ||
20 | # the handler will be called. | ||
21 | # IOW: short link losses will be ignored, longer ones | ||
22 | # will trigger DHCP reconfiguration and such (see handler code). | ||
18 | 23 | ||
19 | #-a Do not up interface automatically | 24 | #-a Do not up interface automatically |
20 | #-p Dont run script on daemon startup | 25 | #-p Dont run script on daemon startup |