examples/var_service/dhcp_if: make helper scripts more talkative

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2022-05-12 11:07:12 +02:00
parent 1099a27696
commit b9c2108b26
4 changed files with 16 additions and 10 deletions

View File

@ -19,7 +19,7 @@
#let cfg=cfg+1 #let cfg=cfg+1
#if[$cfg]=...; ip[$cfg]=...; ipmask[$cfg]=.../...; gw[$cfg]=...; net[$cfg]=... dns[$cfg]=... #if[$cfg]=...; ip[$cfg]=...; ipmask[$cfg]=.../...; gw[$cfg]=...; net[$cfg]=... dns[$cfg]=...
exec >/dev/null #exec >/dev/null
#exec >"$0.out" # debug #exec >"$0.out" # debug
exec 2>&1 exec 2>&1
@ -31,23 +31,31 @@ test "$ip" || exit 1
if ! test "$mask"; then if ! test "$mask"; then
case "$ip" in case "$ip" in
10.*) 10.*)
echo "mask assumed 8 for ip=$ip"
mask=8;; mask=8;;
192.168.*)
mask=16;;
#172.16-31.x.x #172.16-31.x.x
172.1[6789].*) 172.1[6789].*)
echo "mask assumed 12 for ip=$ip"
mask=12;; mask=12;;
172.2[0123456789].*) 172.2[0123456789].*)
echo "mask assumed 12 for ip=$ip"
mask=12;; mask=12;;
172.3[01].*) 172.3[01].*)
echo "mask assumed 12 for ip=$ip"
mask=12;; mask=12;;
192.168.*)
echo "mask assumed 16 for ip=$ip"
mask=16;;
esac esac
fi fi
# some servers do not return router option. # some servers do not return router option.
# assume DHCP server is the router. # assume DHCP server is the router.
if ! test "$router"; then if ! test "$router"; then
test "$serverid" && router="$serverid" if test "$serverid"; then
router="$serverid"
echo "No 'router' from the server, assuming 'serverid' is the router: $serverid"
fi
fi fi
{ {

View File

@ -19,7 +19,7 @@
#let cfg=cfg+1 #let cfg=cfg+1
#ntpip[$cfg]=... #ntpip[$cfg]=...
exec >/dev/null #exec >/dev/null
#exec >"$0.out" # debug #exec >"$0.out" # debug
exec 2>&1 exec 2>&1

View File

@ -38,12 +38,10 @@ file_ntpconf="$service.ntpconf"
dir_ipconf="/var/run/service/fw" dir_ipconf="/var/run/service/fw"
dir_ntpconf="/var/run/service/ntpd" dir_ntpconf="/var/run/service/ntpd"
exec >/dev/null #exec >/dev/null
#exec >>"$0.out" #debug #exec >"$0.out" #debug
exec 2>&1 exec 2>&1
echo "`date`: Params: $*"
if test x"$1" != x"bound" && test x"$1" != x"renew" ; then if test x"$1" != x"bound" && test x"$1" != x"renew" ; then
# Reconfigure network with this interface disabled # Reconfigure network with this interface disabled
echo "Deconfiguring" echo "Deconfiguring"

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# executed when service is taken down ("sv d .") # executed when service is taken down ("svc -d .")
service=${PWD##*/} service=${PWD##*/}
file_ipconf="$service.ipconf" file_ipconf="$service.ipconf"