aboutsummaryrefslogtreecommitdiff
path: root/dns/dnsmasq-devel/files/dnsmasq.in
diff options
context:
space:
mode:
Diffstat (limited to 'dns/dnsmasq-devel/files/dnsmasq.in')
-rw-r--r--dns/dnsmasq-devel/files/dnsmasq.in99
1 files changed, 99 insertions, 0 deletions
diff --git a/dns/dnsmasq-devel/files/dnsmasq.in b/dns/dnsmasq-devel/files/dnsmasq.in
new file mode 100644
index 000000000000..de9da9249b40
--- /dev/null
+++ b/dns/dnsmasq-devel/files/dnsmasq.in
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: dnsmasq
+# REQUIRE: SERVERS ldconfig
+# BEFORE: DAEMON named
+# KEYWORD: shutdown
+#
+# Start before named so as not to break named_wait if named is
+# enabled and /etc/resolv.conf points to ourselves (dnsmasq).
+#
+#
+# Please add the following line to /etc/rc.conf.local or /etc/rc.conf to
+# enable the dnsmasq service(s):
+#
+# dnsmasq_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable dnsmasq at boot.
+#
+# Further settings you can change in /etc/rc.conf if desired:
+#
+# dnsmasq_conf (path): Set to %%PREFIX%%/etc/dnsmasq.conf by default.
+# Set it to another configuration file if you want.
+#
+# dnsmasq_flags (string): Empty by default. Set it to additional command
+# line arguments if desired.
+#
+# dnsmasq_restart (bool): Set to "YES" by default.
+# If "YES", a "reload" action will trigger a "restart"
+# if the configuration file has changed, to work
+# around a dnsmasq(8) limitation.
+#
+#
+# Additional actions supported by this script:
+#
+# reload Reload database files by sending SIGHUP and SIGUSR2.
+# However, if dnsmasq_restart is true (see above) and the
+# configuration file has changed since this rc script has
+# started dnsmasq, restart it instead.
+#
+# logstats Dump statistics information to where dnsmasq is configured to
+# log (syslog by default). This sends SIGUSR1 to dnsmasq.
+#
+
+. /etc/rc.subr
+
+name=dnsmasq
+rcvar=dnsmasq_enable
+
+command="%%PREFIX%%/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+# timestamp (below) is used to check if "reload" should be a "restart" instead
+timestamp="/var/run/${name}.stamp"
+
+load_rc_config "${name}"
+
+: ${dnsmasq_enable="NO"}
+: ${dnsmasq_conf="%%PREFIX%%/etc/${name}.conf"}
+: ${dnsmasq_restart="YES"}
+
+command_args="-x $pidfile -C $dnsmasq_conf"
+
+required_files="${dnsmasq_conf}"
+extra_commands="reload logstats"
+
+reload_precmd="reload_pre"
+reload_postcmd="reload_post"
+start_postcmd="timestampconf"
+stop_precmd="rmtimestamp"
+logstats_cmd="logstats"
+
+reload_pre() {
+ if [ "$dnsmasq_conf" -nt "${timestamp}" ] ; then
+ if checkyesno dnsmasq_restart ; then
+ info "restart: $dnsmasq_conf changed"
+ exec "$0" restart
+ else
+ warn "restart required, $dnsmasq_conf changed"
+ fi
+ fi
+}
+
+reload_post() {
+ kill -USR2 ${rc_pid}
+}
+
+logstats() {
+ kill -USR1 ${rc_pid}
+}
+
+timestampconf() {
+ touch -r "${dnsmasq_conf}" "${timestamp}"
+}
+
+rmtimestamp() {
+ rm -f "${timestamp}"
+}
+
+run_rc_command "$1"