summaryrefslogtreecommitdiffstats
path: root/abs/extra/dnsmasq/rc.dnsmasq
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-08-07 19:44:50 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-08-07 19:44:50 (GMT)
commitc7d5220cabb6b67862e1bfa188c07e0d3821a294 (patch)
treef36132c071183cd86a6f7dd720ea054c74e1c9f0 /abs/extra/dnsmasq/rc.dnsmasq
parentfb1608aa973e24afe26c8fc754ddd11d9466d8ca (diff)
downloadlinhes_pkgbuild-c7d5220cabb6b67862e1bfa188c07e0d3821a294.zip
linhes_pkgbuild-c7d5220cabb6b67862e1bfa188c07e0d3821a294.tar.gz
linhes_pkgbuild-c7d5220cabb6b67862e1bfa188c07e0d3821a294.tar.bz2
dnsmasq 2.62
Diffstat (limited to 'abs/extra/dnsmasq/rc.dnsmasq')
-rwxr-xr-xabs/extra/dnsmasq/rc.dnsmasq58
1 files changed, 43 insertions, 15 deletions
diff --git a/abs/extra/dnsmasq/rc.dnsmasq b/abs/extra/dnsmasq/rc.dnsmasq
index 1676072..4030c28 100755
--- a/abs/extra/dnsmasq/rc.dnsmasq
+++ b/abs/extra/dnsmasq/rc.dnsmasq
@@ -2,35 +2,63 @@
. /etc/rc.conf
. /etc/rc.d/functions
+. /etc/conf.d/dnsmasq
-PID=`pidof -o %PPID /usr/sbin/dnsmasq`
-case "$1" in
+checkconfig() {
+ local testout
+
+ if ! testout=$(/usr/bin/dnsmasq --test 2>&1); then
+ echo "$testout"
+ return 1
+ fi
+
+ return 0
+}
+
+pidfile=/run/dnsmasq.pid
+if [[ -r $pidfile ]]; then
+ read -r PID < "$pidfile"
+ if [[ ! -d /proc/$PID ]]; then
+ # stale pidfile
+ unset PID
+ rm -f "$pidfile"
+ fi
+fi
+
+case $1 in
start)
stat_busy "Starting DNS/DHCP daemon"
- [ -z "$PID" ] && /usr/sbin/dnsmasq
- if [ $? -gt 0 ] ; then
- stat_fail
+ if [[ -z $PID ]] && checkconfig &&
+ /usr/bin/dnsmasq "--user=${DNSMASQ_USER:-nobody}" \
+ "--pid-file=$pidfile" \
+ "${DNSMASQ_OPTS[@]}"; then
+ add_daemon dnsmasq
+ stat_done
else
- add_daemon dnsmasq # create the 'state' dir
- stat_done
+ stat_fail
fi
;;
stop)
stat_busy "Stopping DNS/DHCP daemon"
- [ "$PID" ] && kill $PID &> /dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- else
- rm_daemon dnsmasq # remove the 'state' dir
+ if [[ $PID ]] && kill "$PID" &> /dev/null; then
+ # dnsmasq doesn't clean up after itself
+ rm -f "$pidfile"
+ rm_daemon dnsmasq
stat_done
+ else
+ stat_fail
fi
;;
restart)
$0 stop
- sleep 5
+ sleep 1
$0 start
;;
+ checkconfig)
+ # diagnostics will be printed, with zero/non-zero exit
+ /usr/bin/dnsmasq --test
+ ;;
*)
- echo "usage: $0 {start|stop|restart}"
+ echo "usage: $0 <start|stop|restart|checkconfig>"
esac
-exit 0
+