summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support/dnsmasq/files/init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-networking/recipes-support/dnsmasq/files/init')
-rw-r--r--meta-networking/recipes-support/dnsmasq/files/init69
1 files changed, 67 insertions, 2 deletions
diff --git a/meta-networking/recipes-support/dnsmasq/files/init b/meta-networking/recipes-support/dnsmasq/files/init
index d1aa9e517..51c95dfed 100644
--- a/meta-networking/recipes-support/dnsmasq/files/init
+++ b/meta-networking/recipes-support/dnsmasq/files/init
@@ -8,15 +8,68 @@ test -f $DAEMON || exit 0
8 8
9set -e 9set -e
10 10
11if [ -r /etc/default/$NAME ]
12then
13 . /etc/default/$NAME
14fi
15
16DNSMASQ_CONF="/etc/dnsmasq.conf"
17test "/etc/dnsmasq.d/*" != '/etc/dnsmasq.d/*' && DNSMASQ_CONF="${DNSMASQ_CONF} /etc/dnsmasq.d/*"
18
19test -z "${PIDFILE}" && PIFILE="/run/dnsmasq.pid"
20
21if [ -z "$IGNORE_RESOLVCONF" ]
22then
23 egrep -h -q '^no-resolv' ${DNSMASQ_CONF} && IGNORE_RESOLVCONF="yes"
24fi
25
26# RESOLV_CONF:
27# If the resolvconf package is installed then use the resolv conf file
28# that it provides as the default. Otherwise use /etc/resolv.conf as
29# the default.
30#
31# If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit
32# filename is set there then this inhibits the use of the resolvconf-provided
33# information.
34#
35# Note that if the resolvconf package is installed it is not possible to
36# override it just by configuration in /etc/dnsmasq.conf, it is necessary
37# to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq.
38
39test -z "$RESOLV_CONF" -a "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf && \
40 RESOLV_CONF=/run/dnsmasq/resolv.conf
41
42start_resolvconf()
43{
44 if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ]
45 then
46 echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.$NAME
47 fi
48 :
49}
50
51stop_resolvconf()
52{
53 if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ]
54 then
55 /sbin/resolvconf -d lo.$NAME
56 fi
57 :
58}
59
11case "$1" in 60case "$1" in
12 start) 61 start)
13 echo -n "starting $DESC: $NAME... " 62 echo -n "starting $DESC: $NAME... "
14 test -d /var/lib/misc/ || mkdir /var/lib/misc/ 63 test -d /var/lib/misc/ || mkdir /var/lib/misc/
15 start-stop-daemon -S -x $DAEMON -- $ARGS 64 start-stop-daemon -S -x $DAEMON -- $ARGS \
65 ${RESOLV_CONF:+ -r $RESOLV_CONF} \
66 ${PIDFILE:+ -x $PIDFILE}
67 test $? -eq 0 && start_resolvconf
16 echo "done." 68 echo "done."
17 ;; 69 ;;
18 stop) 70 stop)
19 echo -n "stopping $DESC: $NAME... " 71 echo -n "stopping $DESC: $NAME... "
72 stop_resolvconf
20 start-stop-daemon -K -x $DAEMON 73 start-stop-daemon -K -x $DAEMON
21 echo "done." 74 echo "done."
22 ;; 75 ;;
@@ -25,7 +78,7 @@ case "$1" in
25 start-stop-daemon -q -K -t -x $DAEMON 78 start-stop-daemon -q -K -t -x $DAEMON
26 RET=$? 79 RET=$?
27 if [ "$RET" = "0" ]; then 80 if [ "$RET" = "0" ]; then
28 PID=`cat /var/run/dnsmasq.pid` 81 PID=`cat ${PIDFILE}`
29 echo "($PID) is running" 82 echo "($PID) is running"
30 else 83 else
31 echo "is not running" 84 echo "is not running"
@@ -43,6 +96,18 @@ case "$1" in
43 killall -HUP $(basename ${DAEMON}) 96 killall -HUP $(basename ${DAEMON})
44 echo "done." 97 echo "done."
45 ;; 98 ;;
99 systemd-start-resolvconf)
100 start_resolvconf
101 ;;
102 systemd-stop-resolvconf)
103 stop_resolvconf
104 ;;
105 systemd-exec)
106 test -d /var/lib/misc/ || mkdir /var/lib/misc/
107 exec $DAEMON --keep-in-foreground $ARGS \
108 ${RESOLV_CONF:+ -r $RESOLV_CONF} \
109 ${PIDFILE:+ -x $PIDFILE}
110 ;;
46 *) 111 *)
47 echo "Usage: $0 {start|stop|status|restart|reload}" 112 echo "Usage: $0 {start|stop|status|restart|reload}"
48 exit 1 113 exit 1