2 ########################################################################
3 # Begin $rc_base/init.d/dnsmasq
5 # Description : dnsmasq init script
7 # Authors : Michael Tremer - mitch@ipfire.org
13 ########################################################################
18 # Pull custom configuration file
19 if [ -e "/etc/sysconfig/dnsmasq" ]; then
20 .
/etc
/sysconfig
/dnsmasq
25 function dns_forward_args
() {
28 # Do nothing if file is empty.
29 [ -s "${file}" ] ||
return
33 local enabled zone server remark
34 while IFS
="," read -r enabled zone server remark
; do
35 # Line must be enabled.
36 [ "${enabled}" = "on" ] ||
continue
38 cmdline
="${cmdline} --server=/${zone}/${server}"
47 # kill already running copy of dnsmasq...
48 killproc
/usr
/sbin
/dnsmasq
2>&1 > /dev
/null
50 boot_mesg
"Starting Domain Name Service Proxy..."
52 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
54 [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS
="$ARGS -s $DOMAIN_NAME_GREEN"
56 echo > /var
/ipfire
/red
/resolv.conf
# Clear it
57 if [ -e "/var/ipfire/red/dns1" ]; then
58 DNS1
=$
(cat /var
/ipfire
/red
/dns1
2>/dev
/null
)
59 if [ ! -z ${DNS1} ]; then
60 echo "nameserver ${DNS1}" >> /var
/ipfire
/red
/resolv.conf
63 if [ -e "/var/ipfire/red/dns2" ]; then
64 DNS2
=$
(cat /var
/ipfire
/red
/dns2
2>/dev
/null
)
65 if [ ! -z ${DNS2} ]; then
66 echo "nameserver ${DNS2}" >> /var
/ipfire
/red
/resolv.conf
69 [ -e "/var/ipfire/red/active" ] && ARGS
="$ARGS -r /var/ipfire/red/resolv.conf"
71 ARGS
="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`"
73 # Add custom forward dns zones.
74 ARGS
="${ARGS} $(dns_forward_args /var/ipfire/dnsforward/config)"
76 loadproc
/usr
/sbin
/dnsmasq
-l /var
/state
/dhcp
/dhcpd.leases
$ARGS
78 if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
79 boot_mesg
"Using DNS server(s): ${DNS1} ${DNS2}"
85 boot_mesg
"Stopping Domain Name Service Proxy..."
86 killproc
/usr
/sbin
/dnsmasq
96 statusproc
/usr
/sbin
/dnsmasq
100 echo "Usage: ${0} {start|stop|restart|status}"
105 # End $rc_base/init.d/dnsmasq