]>
Commit | Line | Data |
---|---|---|
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 |
19 | if [ -e "/etc/sysconfig/dnsmasq" ]; then | |
20 | . /etc/sysconfig/dnsmasq | |
21 | fi | |
22 | ||
f480386f MT |
23 | SHOW_SRV=1 |
24 | ||
d1e90efc MT |
25 | case "${1}" in |
26 | start) | |
fcfd54ba AF |
27 | # kill already running copy of dnsmasq... |
28 | killproc /usr/sbin/dnsmasq 2>&1 > /dev/null | |
29 | ||
d1e90efc MT |
30 | boot_mesg "Starting Domain Name Service Proxy..." |
31 | ||
32 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
33 | ARGS= | |
f480386f MT |
34 | [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS="-s $DOMAIN_NAME_GREEN" |
35 | ||
36 | echo > /var/ipfire/red/resolv.conf # Clear it | |
37 | if [ -e "/var/ipfire/red/dns1" ]; then | |
38 | DNS1=$(cat /var/ipfire/red/dns1 2>/dev/null) | |
2789f357 AF |
39 | if [ ! -z ${DNS1} ]; then |
40 | echo "nameserver ${DNS1}" >> /var/ipfire/red/resolv.conf | |
41 | fi | |
f480386f MT |
42 | fi |
43 | if [ -e "/var/ipfire/red/dns2" ]; then | |
44 | DNS2=$(cat /var/ipfire/red/dns2 2>/dev/null) | |
2789f357 AF |
45 | if [ ! -z ${DNS2} ]; then |
46 | echo "nameserver ${DNS2}" >> /var/ipfire/red/resolv.conf | |
47 | fi | |
f480386f MT |
48 | fi |
49 | [ -e "/var/ipfire/red/active" ] && ARGS="$ARGS -r /var/ipfire/red/resolv.conf" | |
d1e90efc | 50 | |
63aceb22 | 51 | ARGS="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`" |
16a61778 MT |
52 | ARGS="$ARGS $CUSTOM_ARGS" |
53 | ||
d1e90efc | 54 | loadproc /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS |
f480386f MT |
55 | |
56 | if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then | |
57 | boot_mesg "Using DNS server(s): ${DNS1} ${DNS2}" | |
58 | boot_mesg_flush | |
59 | fi | |
d1e90efc MT |
60 | ;; |
61 | ||
62 | stop) | |
63 | boot_mesg "Stopping Domain Name Service Proxy..." | |
64 | killproc /usr/sbin/dnsmasq | |
65 | ;; | |
66 | ||
67 | restart) | |
68 | ${0} stop | |
69 | sleep 1 | |
70 | ${0} start | |
71 | ;; | |
72 | ||
73 | status) | |
74 | statusproc /usr/sbin/dnsmasq | |
75 | ;; | |
76 | ||
77 | *) | |
78 | echo "Usage: ${0} {start|stop|restart|status}" | |
79 | exit 1 | |
80 | ;; | |
81 | esac | |
82 | ||
83 | # End $rc_base/init.d/dnsmasq |