aboutsummaryrefslogtreecommitdiff
path: root/src/dnsmasq
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
commit16262790cb6ddacf6c632625cc865e03b1b8671f (patch)
tree09898d65deef518380915ecdc7575756c9ca8595 /src/dnsmasq
parent7bb1499a7cd539f714bb7f603d7fc0a38fd8a963 (diff)
downloadrcdscripts-16262790cb6ddacf6c632625cc865e03b1b8671f.tar.xz
rcdscripts: import first snapshot of rc.d scripts as of 11.25.20122012.11.25
In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable.
Diffstat (limited to 'src/dnsmasq')
-rwxr-xr-xsrc/dnsmasq/rc.dnsmasq64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/dnsmasq/rc.dnsmasq b/src/dnsmasq/rc.dnsmasq
new file mode 100755
index 0000000..4030c28
--- /dev/null
+++ b/src/dnsmasq/rc.dnsmasq
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/dnsmasq
+
+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"
+ if [[ -z $PID ]] && checkconfig &&
+ /usr/bin/dnsmasq "--user=${DNSMASQ_USER:-nobody}" \
+ "--pid-file=$pidfile" \
+ "${DNSMASQ_OPTS[@]}"; then
+ add_daemon dnsmasq
+ stat_done
+ else
+ stat_fail
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping DNS/DHCP daemon"
+ 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 1
+ $0 start
+ ;;
+ checkconfig)
+ # diagnostics will be printed, with zero/non-zero exit
+ /usr/bin/dnsmasq --test
+ ;;
+ *)
+ echo "usage: $0 <start|stop|restart|checkconfig>"
+esac
+