dnsmasq: Make command line customizeable.
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / dnsmasq
CommitLineData
d1e90efc
MT
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/dnsmasq
4#
5# Description : dnsmasq init script
6#
7# Authors : Michael Tremer - mitch@ipfire.org
8#
9# Version : 01.00
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
16a61778
MT
18# Pull custom configuration file
19if [ -e "/etc/sysconfig/dnsmasq" ]; then
20 . /etc/sysconfig/dnsmasq
21fi
22
f480386f
MT
23SHOW_SRV=1
24
d1e90efc
MT
25case "${1}" in
26 start)
27 boot_mesg "Starting Domain Name Service Proxy..."
28
29 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
30 ARGS=
f480386f
MT
31 [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS="-s $DOMAIN_NAME_GREEN"
32
33 echo > /var/ipfire/red/resolv.conf # Clear it
34 if [ -e "/var/ipfire/red/dns1" ]; then
35 DNS1=$(cat /var/ipfire/red/dns1 2>/dev/null)
2789f357
AF
36 if [ ! -z ${DNS1} ]; then
37 echo "nameserver ${DNS1}" >> /var/ipfire/red/resolv.conf
38 fi
f480386f
MT
39 fi
40 if [ -e "/var/ipfire/red/dns2" ]; then
41 DNS2=$(cat /var/ipfire/red/dns2 2>/dev/null)
2789f357
AF
42 if [ ! -z ${DNS2} ]; then
43 echo "nameserver ${DNS2}" >> /var/ipfire/red/resolv.conf
44 fi
f480386f
MT
45 fi
46 [ -e "/var/ipfire/red/active" ] && ARGS="$ARGS -r /var/ipfire/red/resolv.conf"
d1e90efc 47
63aceb22 48 ARGS="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`"
16a61778
MT
49 ARGS="$ARGS $CUSTOM_ARGS"
50
d1e90efc 51 loadproc /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS
f480386f
MT
52
53 if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
54 boot_mesg "Using DNS server(s): ${DNS1} ${DNS2}"
55 boot_mesg_flush
56 fi
d1e90efc
MT
57 ;;
58
59 stop)
60 boot_mesg "Stopping Domain Name Service Proxy..."
61 killproc /usr/sbin/dnsmasq
62 ;;
63
64 restart)
65 ${0} stop
66 sleep 1
67 ${0} start
68 ;;
69
70 status)
71 statusproc /usr/sbin/dnsmasq
72 ;;
73
74 *)
75 echo "Usage: ${0} {start|stop|restart|status}"
76 exit 1
77 ;;
78esac
79
80# End $rc_base/init.d/dnsmasq