summaryrefslogtreecommitdiff
path: root/dns/dnsmasq
diff options
context:
space:
mode:
authorMatthias Andree <mandree@FreeBSD.org>2011-02-22 19:20:17 +0000
committerMatthias Andree <mandree@FreeBSD.org>2011-02-22 19:20:17 +0000
commita4a731547c58f029b82e0328c5173bbbc9e51b2f (patch)
tree78cb6c2df21d0ebd2bbeb9cbaff54edb420138dc /dns/dnsmasq
parent- Update to 0.86 (diff)
Update dnsmasq rc.d script again (sorry for the churn with portrev. 1)
- Start before named, to unbreak named_wait if /etc/resolv.conf points to dnsmasq (when named is the resolver that dnsmasq forwards to). Is also more robust/maintenance friendly if other scripts depend on "named". - Track if the configuration has changed since start, and upgrade reload to restart by default in that case (can be disabled with dnsmasq_restart="NO" in /etc/rc.conf[.local]), to work around dnsmasq shortcoming - Add a "logstats" action to the rcscript, and document it. - Document the "reload" action and the new dnsmasq_restart variable. - Properly quote variable expansions. - Enhance pkg-message to point to the rcfile for feature documentation. - Bump PORTREVISION to 2.
Notes
Notes: svn path=/head/; revision=269514
Diffstat (limited to 'dns/dnsmasq')
-rw-r--r--dns/dnsmasq/Makefile2
-rw-r--r--dns/dnsmasq/files/dnsmasq.sh.in78
-rw-r--r--dns/dnsmasq/files/pkg-message.in5
3 files changed, 69 insertions, 16 deletions
diff --git a/dns/dnsmasq/Makefile b/dns/dnsmasq/Makefile
index e107b56fcc6a..f02f56947dfc 100644
--- a/dns/dnsmasq/Makefile
+++ b/dns/dnsmasq/Makefile
@@ -7,7 +7,7 @@
PORTNAME= dnsmasq
PORTVERSION= 2.57
-PORTREVISION= 1
+PORTREVISION= 2
PORTEPOCH= 1
CATEGORIES= dns ipv6
MASTER_SITES= http://www.thekelleys.org.uk/dnsmasq/ \
diff --git a/dns/dnsmasq/files/dnsmasq.sh.in b/dns/dnsmasq/files/dnsmasq.sh.in
index 8cdd860f3762..a56289ab2d22 100644
--- a/dns/dnsmasq/files/dnsmasq.sh.in
+++ b/dns/dnsmasq/files/dnsmasq.sh.in
@@ -1,21 +1,16 @@
#! /bin/sh
#
# PROVIDE: dnsmasq
-# REQUIRE: SERVERS named
-# BEFORE: DAEMON ntpdate rpcbind
+# REQUIRE: SERVERS
+# BEFORE: DAEMON named
# KEYWORD: shutdown
#
-# The BEFORE: line above contains individual services that have a
-# REQUIRE: named line, to make sure dnsmasq starts early enough
-# for those, in case dnsmasq is listed in /etc/resolv.conf.
-#
-# The REQUIRE: named above is for configurations where named
-# acts as a resolver, and dnsmasq is used to "blend in" local
-# domain names.
+# Start before named so as not to break named_wait if named is
+# enabled and /etc/resolv.conf points to ourselves (dnsmasq).
#
#
-# Add the following line to /etc/rc.conf.local or /etc/rc.conf
-# to enable this service:
+# 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.
@@ -28,6 +23,22 @@
# 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
@@ -35,15 +46,52 @@ name=dnsmasq
rcvar=$(set_rcvar)
command="%%PREFIX%%/sbin/${name}"
-extra_commands=reload
-pidfile=/var/run/${name}.pid
+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}
+load_rc_config "${name}"
: ${dnsmasq_enable="NO"}
: ${dnsmasq_conf="%%PREFIX%%/etc/${name}.conf"}
-required_files=${dnsmasq_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"
diff --git a/dns/dnsmasq/files/pkg-message.in b/dns/dnsmasq/files/pkg-message.in
index 4d13bc7f4fcd..4ec9add459b7 100644
--- a/dns/dnsmasq/files/pkg-message.in
+++ b/dns/dnsmasq/files/pkg-message.in
@@ -1,2 +1,7 @@
+
*** To enable dnsmasq, edit %%PREFIX%%/etc/dnsmasq.conf and
*** set dnsmasq_enable="YES" in /etc/rc.conf[.local]
+***
+*** Further options and actions are documented inside
+*** %%PREFIX%%/etc/rc.d/dnsmasq
+