#dnsmod
writeDnsmasqConf()
{
case `echo "ar7cfg.ethmode" | ar7cfgctl -s` in
ethmode_bridge)
interfaces="lan"
ar7cfgnode="brinterfaces";;
ethmode_router)
interfaces=`echo "ar7cfg.brinterfaces.interfaces" | ar7cfgctl -s | tr -d "\","`
ar7cfgnode="ethinterfaces";;
*)
return 0;;
esac
sv="10.1.1.1"
echo "#modDnsMasq" > $1
echo "read-ethers" >> $1
echo "domain=XXXX.YYYY" >> $1
echo "server=/XXXX.YYYY/$sv" >> $1
echo "dhcp-option=4,$sv" >> $1
echo "dhcp-option=44,$sv" >> $1
echo "addn-hosts=/var/tmp/hosts" >> $1
echo "dhcp-leasefile=/var/tmp/dhcp.leases" >> $1
ret=0
for interface in $interfaces;do
if [ "`echo "ar7cfg.$ar7cfgnode[$interface].dhcpenabled" | ar7cfgctl -s`" = "yes" ] ; then
ipaddr=`echo "ar7cfg.$ar7cfgnode[$interface].ipaddr" | ar7cfgctl -s`
echo "dhcp-range=$interface,`echo "ar7cfg.$ar7cfgnode[$interface].dhcpstart" | ar7cfgctl -s`,`echo "ar7cfg.$ar7cfgnode[$interface].dhcpend" | ar7cfgctl -s`" >> $1
echo "dhcp-option=$interface,3,$ipaddr" >> $1
echo "dhcp-option=$interface,6,$ipaddr" >> $1
ret=1
else
echo "no-dhcp-interface=$interface" >> $1
fi
done
return $ret
}
cfd="/var/tmp/dnsmasq.conf"
tmp="/var/tmp/ar7.org"
mod="/var/tmp/ar7.mod"
cfg="/var/flash/ar7.cfg"
if [ ! -s "$cfd" ] ; then
if [ -z "`pidof multid`" ] ; then
multid
sleep 1
fi
fi
if [ -n "`pidof dnsmasq`" ] ; then
killall dnsmasq
fi
if [ -n "`pidof multid`" ] ; then
multid -s
sleep 1
fi
if [ "$1" != "-s" ] ; then
writeDnsmasqConf $cfd
if [ "$?" = "1" ] ; then
dnsmasq -C "$cfd"
cat $cfg > $tmp
sed "s/dhcpenabled = yes/dhcpenabled = no/" $tmp > $mod
cat $mod > $cfg
eval multid $1
ret=$?
sleep 1
cat $tmp > $cfg
rm $tmp
rm $mod
else
dnsmasq -C "$cfd"
eval multid $1
ret=$?
fi
fi
exit $ret
#dnsmod