2009-11-06 03:04:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# convert:
|
|
|
|
|
|
|
|
# dhcptype=5
|
|
|
|
# serverid=172.16.42.102
|
|
|
|
# lease=97200
|
|
|
|
# interface=eth0
|
|
|
|
# ip=172.16.42.177
|
|
|
|
# subnet=255.255.255.0
|
|
|
|
# mask=24
|
|
|
|
# broadcast=172.16.22.255
|
|
|
|
# router=172.16.42.98
|
|
|
|
# dns=10.34.32.125 10.32.63.5 10.34.255.7 10.11.255.27
|
|
|
|
# domain=lab.example.com example.com
|
|
|
|
# ntpsrv=10.34.32.125 10.34.255.7
|
|
|
|
|
|
|
|
# into:
|
|
|
|
|
|
|
|
#let cfg=cfg+1
|
|
|
|
#if[$cfg]=...; ip[$cfg]=...; ipmask[$cfg]=.../...; gw[$cfg]=...; net[$cfg]=... dns[$cfg]=...
|
|
|
|
|
2009-11-09 08:39:50 +00:00
|
|
|
exec >/dev/null
|
|
|
|
#exec >"$0.out" # debug
|
|
|
|
exec 2>&1
|
2009-11-06 03:04:19 +00:00
|
|
|
|
|
|
|
test "$interface" || exit 1
|
2009-11-09 08:39:50 +00:00
|
|
|
test "$ip" || exit 1
|
2009-11-06 03:04:19 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
echo "let cfg=cfg+1"
|
2010-01-25 12:39:24 +00:00
|
|
|
test "$interface" && echo "if[\$cfg]='$interface'"
|
2009-11-06 03:04:19 +00:00
|
|
|
test "$ip" && echo "ip[\$cfg]='$ip'"
|
|
|
|
test "$ip" && test "$mask" \
|
|
|
|
&& echo "ipmask[\$cfg]='$ip/$mask'"
|
|
|
|
test "$router" && echo "gw[\$cfg]='$router'"
|
|
|
|
test "$dns" && echo "dns[\$cfg]='$dns'"
|
|
|
|
# TODO: I never saw a dhcp server which correctly announces
|
|
|
|
# which subnet(s) is/are available thru advertised router
|
|
|
|
# Assume 0/0
|
|
|
|
echo "net[\$cfg]='0/0'"
|
2009-11-09 08:39:50 +00:00
|
|
|
} >"$1"
|