update network service examples
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 24 Oct 2015 12:55:33 +0000 (14:55 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 24 Oct 2015 12:55:33 +0000 (14:55 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
17 files changed:
examples/var_service/dhcp_if/convert2ntpconf
examples/var_service/dhcp_if/dhcp_handler
examples/var_service/dhcp_if/finish [new file with mode: 0755]
examples/var_service/dhcp_if/log/run
examples/var_service/dhcp_if_pinger/run
examples/var_service/ftpd/log/run
examples/var_service/fw/run
examples/var_service/httpd/log/run
examples/var_service/ifplugd_if/log/run
examples/var_service/ifplugd_if/run
examples/var_service/inetd/log/run
examples/var_service/ntpd/log/run
examples/var_service/ntpd/run
examples/var_service/tftpd/log/run
examples/var_service/zcip_if/finish [new file with mode: 0755]
examples/var_service/zcip_if/log/run
examples/var_service/zcip_if/zcip_handler

index debf1ebfe7ca0a9a3b8e52e6994e9611ac8bc246..e9d829308f608d41a2b39761bd726dff14b13848 100755 (executable)
@@ -29,6 +29,6 @@ test "$ip" || exit 1
 {
 for n in $ntpsrv; do
        echo "let cfg=cfg+1"
-       echo "ntpip[\$cfg]='$n'";
+       echo "ntpip[\$cfg]='$n'"
 done
 } >"$1"
index 927e02a176c72ec1261e8580cb18aae40f437a59..3d2a5cb791bb9428f0830cae62a34c52265015ff 100755 (executable)
@@ -36,7 +36,7 @@ service=${PWD##*/}
 file_ipconf="$service.ipconf"
 file_ntpconf="$service.ntpconf"
 dir_ipconf="/var/run/service/fw"
-dir_ntpconf="/var/run/service/ntp"
+dir_ntpconf="/var/run/service/ntpd"
 
 exec >/dev/null
 #exec >>"$0.out"  #debug
@@ -47,7 +47,7 @@ echo "`date`: Params: $*"
 if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
        # Reconfigure network with this interface disabled
        echo "Deconfiguring"
-       rm "$service.out"
+       rm "env.out"
        rm "$file_ipconf"
        rm "$file_ntpconf"
        rm "$dir_ipconf/$file_ipconf"
@@ -57,7 +57,8 @@ if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
 fi
 
 # Bound: we've got the lease
-#env >"$service.out"  # debug
+# Record information for e.g. dhcp_$IF_pinger service
+env >"env.out"
 
 ./convert2ipconf "$file_ipconf"
 # Reconfigure routing and firewall if needed
@@ -69,7 +70,7 @@ if test $? != 0; then
        sv u /var/service/fw
 fi
 
-if test -d /var/service/ntp; then
+if test -d /var/service/ntpd; then
        ./convert2ntpconf "$file_ntpconf"
        # Reconfigure ntp server addresses if needed
        diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1
@@ -77,7 +78,7 @@ if test -d /var/service/ntp; then
                echo "Reconfiguring ntp"
                mkdir -p "$dir_ntpconf" 2>/dev/null
                cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf"
-               sv t /var/service/ntp
-               sv u /var/service/ntp
+               sv t /var/service/ntpd
+               sv u /var/service/ntpd
        fi
 fi
diff --git a/examples/var_service/dhcp_if/finish b/examples/var_service/dhcp_if/finish
new file mode 100755 (executable)
index 0000000..5e7667a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# executed when service is taken down ("sv d .")
+
+service=${PWD##*/}
+file_ipconf="$service.ipconf"
+file_ntpconf="$service.ntpconf"
+dir_ipconf="/var/run/service/fw"
+dir_ntpconf="/var/run/service/ntpd"
+
+# Reconfigure network with this interface disabled
+echo "Finish: deconfiguring"
+rm "env.out"
+rm "$file_ipconf"
+rm "$file_ntpconf"
+rm "$dir_ipconf/$file_ipconf"
+rm "$dir_ntpconf/$file_ntpconf"
+sv u /var/service/fw
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 1868510d1e05a1abd7d235f43f464df619a73da4..e0e87a16ab22103ab150a568a3066643b3fd6237 100755 (executable)
@@ -21,9 +21,9 @@ if test -f "$0.log"; then
        mv "$0.log.new" "$0.log"
 fi
 
-test -f "/var/service/dhcp_$if/dhcp_$if.out" || exec env - sleep "$ping_time"
+test -f "/var/service/dhcp_$if/env.out" || exec env - sleep "$ping_time"
 
-. "/var/service/dhcp_$if/dhcp_$if.out"
+. "/var/service/dhcp_$if/env.out"
 test x"$router" != x"" || exec env - sleep "$ping_time"
 
 #msg "Pinging $router"
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 396b678ab889c04eb73a86cbb9d2fdcb40556501..81c7f2e7cfa1e20a821f1ccf8d05ebeb53df2e74 100755 (executable)
@@ -62,7 +62,7 @@ umask 077
 
 # Make sure rundir/ exists
 mkdir -p "$rundir" 2>/dev/null
-chown -R "$user:" "$rundir"
+chown -R "$user": "$rundir"
 chmod -R a=rX "$rundir"
 rm -rf rundir 2>/dev/null
 ln -s "$rundir" rundir
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 2781cf9f9f0f3ad58a75d75b4b028c45d1c9f138..c4f766e8801aae1f5cd52486808dd72354da52cd 100755 (executable)
@@ -8,6 +8,9 @@ pwd="$PWD"
 
 if="${PWD##*/ifplugd_}"
 
+echo "* Upping iface $if"
+ip link set dev "$if" up
+
 echo "* Starting ifplugd on $if [$$]"
 exec \
 env - PATH="$PATH" \
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 581d231a39d10d0822a6c9c5cfbfe37d8f207622..6f2a681883ad081ae889ad97d3a0224e9b425dd7 100755 (executable)
@@ -15,7 +15,7 @@ default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool"
 
 # Make sure rundir/ exists
 mkdir -p "$rundir" 2>/dev/null
-chown -R "$user:" "$rundir"
+chown -R "$user": "$rundir"
 chmod -R a=rX "$rundir"
 rm -rf rundir 2>/dev/null
 ln -s "$rundir" rundir
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # 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 (executable)
index 0000000..95995cf
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+# executed when service is taken down ("sv d .")
+
+service=${PWD##*/}
+file_ipconf="$service.ipconf"
+dir_ipconf="/var/run/service/fw"
+
+# Reconfigure network with this interface disabled
+echo "Finish: deconfiguring"
+rm "env.out"
+rm "$file_ipconf"
+rm "$dir_ipconf/$file_ipconf"
+sv u /var/service/fw
index 560d1b19f64b58a10b2a51541e3b1b9c03ff2866..69d74b73f53774225704a523f7fcf2b67879280a 100755 (executable)
@@ -6,7 +6,7 @@ logdir="/var/log/service/`(cd ..;basename $PWD)`"
 mkdir -p "$logdir" 2>/dev/null
 chown -R "$user": "$logdir"
 chmod -R go-rwxst,u+rwX "$logdir"
-rm logdir
+rm -rf logdir
 ln -s "$logdir" logdir
 
 # make this dir accessible to logger
index 13010db27546a322fad2c9969340d0dd73a6a531..3c6ca788bdbda394f8b73412a4fdfdb1b52c213c 100755 (executable)
@@ -33,7 +33,8 @@ if test x"$1" != x"config"; then
 fi
 
 # "config": we've got the address
-#env # debug
+# Record information for e.g. dhcp_$IF_pinger service
+env >"env.out"
 
 ./convert2ipconf "$file_ipconf"
 # Reconfigure routing and firewall if needed