X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=meta-stx%2Frecipes-support%2Fdnsmasq%2Fdnsmasq%2Finit;fp=meta-stx%2Frecipes-support%2Fdnsmasq%2Fdnsmasq%2Finit;h=51c95dfedd58798ff362009d70d929ae912e6629;hb=d41692264a2b1a54082ef936d2830cd9d4fa6b62;hp=0000000000000000000000000000000000000000;hpb=4bed284cd2c43e567f233632ae159b6395b05995;p=pti%2Frtp.git diff --git a/meta-stx/recipes-support/dnsmasq/dnsmasq/init b/meta-stx/recipes-support/dnsmasq/dnsmasq/init new file mode 100644 index 0000000..51c95df --- /dev/null +++ b/meta-stx/recipes-support/dnsmasq/dnsmasq/init @@ -0,0 +1,117 @@ +#!/bin/sh +DAEMON=/usr/bin/dnsmasq +NAME=dnsmasq +DESC="DNS forwarder and DHCP server" +ARGS="-7 /etc/dnsmasq.d" + +test -f $DAEMON || exit 0 + +set -e + +if [ -r /etc/default/$NAME ] +then + . /etc/default/$NAME +fi + +DNSMASQ_CONF="/etc/dnsmasq.conf" +test "/etc/dnsmasq.d/*" != '/etc/dnsmasq.d/*' && DNSMASQ_CONF="${DNSMASQ_CONF} /etc/dnsmasq.d/*" + +test -z "${PIDFILE}" && PIFILE="/run/dnsmasq.pid" + +if [ -z "$IGNORE_RESOLVCONF" ] +then + egrep -h -q '^no-resolv' ${DNSMASQ_CONF} && IGNORE_RESOLVCONF="yes" +fi + +# RESOLV_CONF: +# If the resolvconf package is installed then use the resolv conf file +# that it provides as the default. Otherwise use /etc/resolv.conf as +# the default. +# +# If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit +# filename is set there then this inhibits the use of the resolvconf-provided +# information. +# +# Note that if the resolvconf package is installed it is not possible to +# override it just by configuration in /etc/dnsmasq.conf, it is necessary +# to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq. + +test -z "$RESOLV_CONF" -a "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf && \ + RESOLV_CONF=/run/dnsmasq/resolv.conf + +start_resolvconf() +{ + if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ] + then + echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.$NAME + fi + : +} + +stop_resolvconf() +{ + if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ] + then + /sbin/resolvconf -d lo.$NAME + fi + : +} + +case "$1" in + start) + echo -n "starting $DESC: $NAME... " + test -d /var/lib/misc/ || mkdir /var/lib/misc/ + start-stop-daemon -S -x $DAEMON -- $ARGS \ + ${RESOLV_CONF:+ -r $RESOLV_CONF} \ + ${PIDFILE:+ -x $PIDFILE} + test $? -eq 0 && start_resolvconf + echo "done." + ;; + stop) + echo -n "stopping $DESC: $NAME... " + stop_resolvconf + start-stop-daemon -K -x $DAEMON + echo "done." + ;; + status) + echo -n "dnsmasq " + start-stop-daemon -q -K -t -x $DAEMON + RET=$? + if [ "$RET" = "0" ]; then + PID=`cat ${PIDFILE}` + echo "($PID) is running" + else + echo "is not running" + exit $RET + fi + ;; + restart) + echo "restarting $DESC: $NAME... " + $0 stop + $0 start + echo "done." + ;; + reload) + echo -n "reloading $DESC: $NAME... " + killall -HUP $(basename ${DAEMON}) + echo "done." + ;; + systemd-start-resolvconf) + start_resolvconf + ;; + systemd-stop-resolvconf) + stop_resolvconf + ;; + systemd-exec) + test -d /var/lib/misc/ || mkdir /var/lib/misc/ + exec $DAEMON --keep-in-foreground $ARGS \ + ${RESOLV_CONF:+ -r $RESOLV_CONF} \ + ${PIDFILE:+ -x $PIDFILE} + ;; + *) + echo "Usage: $0 {start|stop|status|restart|reload}" + exit 1 + ;; +esac + +exit 0