printf "${NEWRESOLV}" > "${DNSMASQRESOLV}"
fi
-[ -x /sbin/runscript ] && INIT_EXTRA="--quiet --nodeps"
-
-if [ "${RELOAD}" = "yes" ]; then
- if [ -x "${PREFIX}"/etc/init.d/dnsmasq ]; then
- /etc/init.d/dnsmasq ${INIT_EXTRA} conditionalrestart
- elif [ -x "${PREFIX}"/etc/rc.d/dnsmasq -a -s /var/run/dnsmasq.pid ]; then
- kill -0 $(cat /var/run/dnsmasq.pid) && \
- "${PREFIX}"/etc/rc.d/dnsmasq restart
- fi
-fi
-
+[ "${RELOAD}" = "yes" ] && resolvconf -s dnsmasq restart
if [ "${DBUS}" = "yes" ]; then
- if [ "${RELOAD}" != "yes" ]; then
- if [ -x "${PREFIX}"/etc/init.d/dnsmasq ]; then
- /etc/init.d/dnsmasq ${INIT_EXTRA} reload
- elif [ -x "${PREFIX}"/etc/rc.d/dnsmasq ]; then
- "${PREFIX}"/etc/rc.d/dnsmasq reload
- fi
- fi
+ [ "${RELOAD}" != "yes" ] && resolvconf -s dnsmasq reload
# Send even if emtpy so old servers are cleared
dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
/uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \
# Create our resolv.conf now
printf "${NEWCONF}" > "${RESOLVCONF}"/run/resolv.conf
-# Restart nscd if it's running
-if [ -x /etc/init.d/nscd ]; then
- if [ -x /sbin/runscript ]; then
- /etc/init.d/nscd --nodeps --quiet conditionalrestart
- else
- /etc/init.d/nscd restart
- fi
-elif [ -x /etc/rc.d/nscd ]; then
- /etc/rc.d/nscd restart
-fi
+resolvconf -s nscd restart
# Notify users of the resolver
for x in "${REVOLVCONF}"/update-libc.d/*; do
RELOAD="yes"
fi
-if [ "${RELOAD}" = "yes" ]; then
- # OpenRC style
- if [ -x /etc/init.d/named ]; then
- if [ -x /sbin/runscript ]; then
- /etc/init.d/named --nodeps --quiet conditionalrestart
- else
- /etc/init.d/named restart
- fi
- fi
- # BSD RC style
- if [ -x /etc/rc.d/named -a -s /var/run/named/pid ]; then
- kill -0 $(cat /var/run/named/pid) && /etc/rc.d/named restart
- fi
-fi
+[ "${RELOAD}" = "yes" ] && resolvconf -s named restart
exit 0
pattern
-v [\$PATTERN] echo NEWDOMAIN, NEWSEARCH and NEWNS variables to
the console
+ -s \$SVC \$CMD Do \$CMD for the system service \$SVC
-h Show this help cruft
EOF
[ -z "$@" ] && exit 0
CMD="$1"
shift
fi
+
+# We do our service restarting here so that our subscribers don't have to know
+# about the OS's init system.
+if [ "x${CMD}" = "x-s" ]; then
+ if [ -n "$1" ]; then
+ SERVICE="$1"
+ shift
+ fi
+ [ -z "${SERVICE}" ] && usage "Service not specified"
+ if [ -n "$1" ]; then
+ ACTION="$1"
+ shift
+ fi
+ [ -z "${ACTION}" ] && usage "Action not specified"
+
+ # If restarting check if service is running or not if we can
+ if [ "x${ACTION}" = "xrestart" ]; then
+ if [ -s /var/run/"${SERVICE}".pid ]; then
+ kill -0 $(cat /var/run/"${SERVICE}".pid)
+ elif [ -s /var/run/"${SERVICE}"/"${SERVICE}".pid ]; then
+ kill -0 $(cat /var/run/"${SERVICE}".pid)
+ elif [ -s /var/run/"${SERVICE}"/pid ]; then
+ kill -0 $(cat /var/run/"${SERVICE}"/pid)
+ else
+ false
+ fi
+ # Service not running, so don't restart
+ [ $? != 0 ] && exit 1
+ fi
+ if [ -x /sbin/service ]; then
+ service "${SERVICE}" "${ACTION}" "$@"
+ elif [ -x /etc/init.d/"${SERVICE}" -a -x /sbin/runscript ]; then
+ if [ "x${ACTION}" = "xrestart" ]; then
+ /etc/init.d/"${SERVICE}" --quiet --nodeps conditionalrestart "$@"
+ else
+ /etc/init.d/"${SERVICE}" --quiet --nodeps "${ACTION}" "$@"
+ fi
+ elif [ -x /etc/init.d/"${SERVICE}" ]; then
+ /etc/init.d/"${SERVICE}" "${ACTION}" "$@"
+ elif [ -x /etc/rc.d/"${SERVICE}" ]; then
+ /etc/rc.d/"${SERVICE}" "${ACTION}" "$@"
+ elif [ -x /etc/rc.d/rc."${SERVICE}" ]; then
+ /etc/rc.d/rc."${SERVICE}" "${ACTION}" "$@"
+ else
+ error_exit "Don't know how to interact with services on this platform"
+ fi
+ exit $?
+fi
+
if [ -n "$1" ]; then
IFACE="$1"
shift
\fB\-i\fR \fIPATTERN\fR
.PP
.B resolvconf
-\fB\-v\fR \fIPATTERN\fr
+\fB\-v\fR \fIPATTERN\fR
+.B resolvconf
+\fB\-s\fR \fISERVICE COMMAND [args]\fR
.SH DESCRIPTION
Overwrite (\fB\-a\fR) or delete (\fB\-d\fR) the nameserver information
record for network interface \fIINTERFACE\fR
With \fB\-v\fR, we echo variables NEWDOMAIN, NEWSEARCH and NEWNS to the
console which can be used to make it easer writing scripts which configure
DNS resolvers.
+.PP
+With \fB\-s\fR, we work out if the service is running by finding its pidfile
+and if it is we restart it. This means that only resolvconf needs to know this
+for supported platforms and subscribers can just call this resolvconf function.
.SH SERVERS
Normally
.B resolvconf