aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-24 14:55:33 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-24 14:55:33 +0200
commit4f8ecf273c4a239d007125f3b96a55100b661c04 (patch)
tree680b7a535f119f2bfb2e820adb2be5d537ccb99a
parentd32a1a4054444d8193736ee4c5f515fa90dbb24f (diff)
downloadbusybox-w32-4f8ecf273c4a239d007125f3b96a55100b661c04.tar.gz
busybox-w32-4f8ecf273c4a239d007125f3b96a55100b661c04.tar.bz2
busybox-w32-4f8ecf273c4a239d007125f3b96a55100b661c04.zip
update network service examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xexamples/var_service/dhcp_if/convert2ntpconf2
-rwxr-xr-xexamples/var_service/dhcp_if/dhcp_handler13
-rwxr-xr-xexamples/var_service/dhcp_if/finish17
-rwxr-xr-xexamples/var_service/dhcp_if/log/run2
-rwxr-xr-xexamples/var_service/dhcp_if_pinger/run4
-rwxr-xr-xexamples/var_service/ftpd/log/run2
-rwxr-xr-xexamples/var_service/fw/run2
-rwxr-xr-xexamples/var_service/httpd/log/run2
-rwxr-xr-xexamples/var_service/ifplugd_if/log/run2
-rwxr-xr-xexamples/var_service/ifplugd_if/run3
-rwxr-xr-xexamples/var_service/inetd/log/run2
-rwxr-xr-xexamples/var_service/ntpd/log/run2
-rwxr-xr-xexamples/var_service/ntpd/run2
-rwxr-xr-xexamples/var_service/tftpd/log/run2
-rwxr-xr-xexamples/var_service/zcip_if/finish13
-rwxr-xr-xexamples/var_service/zcip_if/log/run2
-rwxr-xr-xexamples/var_service/zcip_if/zcip_handler3
17 files changed, 55 insertions, 20 deletions
diff --git a/examples/var_service/dhcp_if/convert2ntpconf b/examples/var_service/dhcp_if/convert2ntpconf
index debf1ebfe..e9d829308 100755
--- a/examples/var_service/dhcp_if/convert2ntpconf
+++ b/examples/var_service/dhcp_if/convert2ntpconf
@@ -29,6 +29,6 @@ test "$ip" || exit 1
29{ 29{
30for n in $ntpsrv; do 30for n in $ntpsrv; do
31 echo "let cfg=cfg+1" 31 echo "let cfg=cfg+1"
32 echo "ntpip[\$cfg]='$n'"; 32 echo "ntpip[\$cfg]='$n'"
33done 33done
34} >"$1" 34} >"$1"
diff --git a/examples/var_service/dhcp_if/dhcp_handler b/examples/var_service/dhcp_if/dhcp_handler
index 927e02a17..3d2a5cb79 100755
--- a/examples/var_service/dhcp_if/dhcp_handler
+++ b/examples/var_service/dhcp_if/dhcp_handler
@@ -36,7 +36,7 @@ service=${PWD##*/}
36file_ipconf="$service.ipconf" 36file_ipconf="$service.ipconf"
37file_ntpconf="$service.ntpconf" 37file_ntpconf="$service.ntpconf"
38dir_ipconf="/var/run/service/fw" 38dir_ipconf="/var/run/service/fw"
39dir_ntpconf="/var/run/service/ntp" 39dir_ntpconf="/var/run/service/ntpd"
40 40
41exec >/dev/null 41exec >/dev/null
42#exec >>"$0.out" #debug 42#exec >>"$0.out" #debug
@@ -47,7 +47,7 @@ echo "`date`: Params: $*"
47if test x"$1" != x"bound" && test x"$1" != x"renew" ; then 47if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
48 # Reconfigure network with this interface disabled 48 # Reconfigure network with this interface disabled
49 echo "Deconfiguring" 49 echo "Deconfiguring"
50 rm "$service.out" 50 rm "env.out"
51 rm "$file_ipconf" 51 rm "$file_ipconf"
52 rm "$file_ntpconf" 52 rm "$file_ntpconf"
53 rm "$dir_ipconf/$file_ipconf" 53 rm "$dir_ipconf/$file_ipconf"
@@ -57,7 +57,8 @@ if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
57fi 57fi
58 58
59# Bound: we've got the lease 59# Bound: we've got the lease
60#env >"$service.out" # debug 60# Record information for e.g. dhcp_$IF_pinger service
61env >"env.out"
61 62
62./convert2ipconf "$file_ipconf" 63./convert2ipconf "$file_ipconf"
63# Reconfigure routing and firewall if needed 64# Reconfigure routing and firewall if needed
@@ -69,7 +70,7 @@ if test $? != 0; then
69 sv u /var/service/fw 70 sv u /var/service/fw
70fi 71fi
71 72
72if test -d /var/service/ntp; then 73if test -d /var/service/ntpd; then
73 ./convert2ntpconf "$file_ntpconf" 74 ./convert2ntpconf "$file_ntpconf"
74 # Reconfigure ntp server addresses if needed 75 # Reconfigure ntp server addresses if needed
75 diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1 76 diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1
@@ -77,7 +78,7 @@ if test -d /var/service/ntp; then
77 echo "Reconfiguring ntp" 78 echo "Reconfiguring ntp"
78 mkdir -p "$dir_ntpconf" 2>/dev/null 79 mkdir -p "$dir_ntpconf" 2>/dev/null
79 cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" 80 cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf"
80 sv t /var/service/ntp 81 sv t /var/service/ntpd
81 sv u /var/service/ntp 82 sv u /var/service/ntpd
82 fi 83 fi
83fi 84fi
diff --git a/examples/var_service/dhcp_if/finish b/examples/var_service/dhcp_if/finish
new file mode 100755
index 000000000..5e7667a2d
--- /dev/null
+++ b/examples/var_service/dhcp_if/finish
@@ -0,0 +1,17 @@
1#!/bin/sh
2# executed when service is taken down ("sv d .")
3
4service=${PWD##*/}
5file_ipconf="$service.ipconf"
6file_ntpconf="$service.ntpconf"
7dir_ipconf="/var/run/service/fw"
8dir_ntpconf="/var/run/service/ntpd"
9
10# Reconfigure network with this interface disabled
11echo "Finish: deconfiguring"
12rm "env.out"
13rm "$file_ipconf"
14rm "$file_ntpconf"
15rm "$dir_ipconf/$file_ipconf"
16rm "$dir_ntpconf/$file_ntpconf"
17sv u /var/service/fw
diff --git a/examples/var_service/dhcp_if/log/run b/examples/var_service/dhcp_if/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/dhcp_if/log/run
+++ b/examples/var_service/dhcp_if/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/dhcp_if_pinger/run b/examples/var_service/dhcp_if_pinger/run
index 1868510d1..e0e87a16a 100755
--- a/examples/var_service/dhcp_if_pinger/run
+++ b/examples/var_service/dhcp_if_pinger/run
@@ -21,9 +21,9 @@ if test -f "$0.log"; then
21 mv "$0.log.new" "$0.log" 21 mv "$0.log.new" "$0.log"
22fi 22fi
23 23
24test -f "/var/service/dhcp_$if/dhcp_$if.out" || exec env - sleep "$ping_time" 24test -f "/var/service/dhcp_$if/env.out" || exec env - sleep "$ping_time"
25 25
26. "/var/service/dhcp_$if/dhcp_$if.out" 26. "/var/service/dhcp_$if/env.out"
27test x"$router" != x"" || exec env - sleep "$ping_time" 27test x"$router" != x"" || exec env - sleep "$ping_time"
28 28
29#msg "Pinging $router" 29#msg "Pinging $router"
diff --git a/examples/var_service/ftpd/log/run b/examples/var_service/ftpd/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/ftpd/log/run
+++ b/examples/var_service/ftpd/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/fw/run b/examples/var_service/fw/run
index 396b678ab..81c7f2e7c 100755
--- a/examples/var_service/fw/run
+++ b/examples/var_service/fw/run
@@ -62,7 +62,7 @@ umask 077
62 62
63# Make sure rundir/ exists 63# Make sure rundir/ exists
64mkdir -p "$rundir" 2>/dev/null 64mkdir -p "$rundir" 2>/dev/null
65chown -R "$user:" "$rundir" 65chown -R "$user": "$rundir"
66chmod -R a=rX "$rundir" 66chmod -R a=rX "$rundir"
67rm -rf rundir 2>/dev/null 67rm -rf rundir 2>/dev/null
68ln -s "$rundir" rundir 68ln -s "$rundir" rundir
diff --git a/examples/var_service/httpd/log/run b/examples/var_service/httpd/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/httpd/log/run
+++ b/examples/var_service/httpd/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/ifplugd_if/log/run b/examples/var_service/ifplugd_if/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/ifplugd_if/log/run
+++ b/examples/var_service/ifplugd_if/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/ifplugd_if/run b/examples/var_service/ifplugd_if/run
index 2781cf9f9..c4f766e88 100755
--- a/examples/var_service/ifplugd_if/run
+++ b/examples/var_service/ifplugd_if/run
@@ -8,6 +8,9 @@ pwd="$PWD"
8 8
9if="${PWD##*/ifplugd_}" 9if="${PWD##*/ifplugd_}"
10 10
11echo "* Upping iface $if"
12ip link set dev "$if" up
13
11echo "* Starting ifplugd on $if [$$]" 14echo "* Starting ifplugd on $if [$$]"
12exec \ 15exec \
13env - PATH="$PATH" \ 16env - PATH="$PATH" \
diff --git a/examples/var_service/inetd/log/run b/examples/var_service/inetd/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/inetd/log/run
+++ b/examples/var_service/inetd/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/ntpd/log/run b/examples/var_service/ntpd/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/ntpd/log/run
+++ b/examples/var_service/ntpd/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/ntpd/run b/examples/var_service/ntpd/run
index 581d231a3..6f2a68188 100755
--- a/examples/var_service/ntpd/run
+++ b/examples/var_service/ntpd/run
@@ -15,7 +15,7 @@ default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool"
15 15
16# Make sure rundir/ exists 16# Make sure rundir/ exists
17mkdir -p "$rundir" 2>/dev/null 17mkdir -p "$rundir" 2>/dev/null
18chown -R "$user:" "$rundir" 18chown -R "$user": "$rundir"
19chmod -R a=rX "$rundir" 19chmod -R a=rX "$rundir"
20rm -rf rundir 2>/dev/null 20rm -rf rundir 2>/dev/null
21ln -s "$rundir" rundir 21ln -s "$rundir" rundir
diff --git a/examples/var_service/tftpd/log/run b/examples/var_service/tftpd/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/tftpd/log/run
+++ b/examples/var_service/tftpd/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/zcip_if/finish b/examples/var_service/zcip_if/finish
new file mode 100755
index 000000000..95995cf5f
--- /dev/null
+++ b/examples/var_service/zcip_if/finish
@@ -0,0 +1,13 @@
1#!/bin/sh
2# executed when service is taken down ("sv d .")
3
4service=${PWD##*/}
5file_ipconf="$service.ipconf"
6dir_ipconf="/var/run/service/fw"
7
8# Reconfigure network with this interface disabled
9echo "Finish: deconfiguring"
10rm "env.out"
11rm "$file_ipconf"
12rm "$dir_ipconf/$file_ipconf"
13sv u /var/service/fw
diff --git a/examples/var_service/zcip_if/log/run b/examples/var_service/zcip_if/log/run
index 560d1b19f..69d74b73f 100755
--- a/examples/var_service/zcip_if/log/run
+++ b/examples/var_service/zcip_if/log/run
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
6mkdir -p "$logdir" 2>/dev/null 6mkdir -p "$logdir" 2>/dev/null
7chown -R "$user": "$logdir" 7chown -R "$user": "$logdir"
8chmod -R go-rwxst,u+rwX "$logdir" 8chmod -R go-rwxst,u+rwX "$logdir"
9rm logdir 9rm -rf logdir
10ln -s "$logdir" logdir 10ln -s "$logdir" logdir
11 11
12# make this dir accessible to logger 12# make this dir accessible to logger
diff --git a/examples/var_service/zcip_if/zcip_handler b/examples/var_service/zcip_if/zcip_handler
index 13010db27..3c6ca788b 100755
--- a/examples/var_service/zcip_if/zcip_handler
+++ b/examples/var_service/zcip_if/zcip_handler
@@ -33,7 +33,8 @@ if test x"$1" != x"config"; then
33fi 33fi
34 34
35# "config": we've got the address 35# "config": we've got the address
36#env # debug 36# Record information for e.g. dhcp_$IF_pinger service
37env >"env.out"
37 38
38./convert2ipconf "$file_ipconf" 39./convert2ipconf "$file_ipconf"
39# Reconfigure routing and firewall if needed 40# Reconfigure routing and firewall if needed