aboutsummaryrefslogtreecommitdiff
path: root/etc/rc.d
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2015-10-19 15:56:59 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2015-10-19 15:56:59 +0000
commiteb860592bdd395b25d606463e965b66d694dff32 (patch)
tree228746e46c0973a734f2c757fc82b3043bd45bf8 /etc/rc.d
parent4955cbf300d4a78d146df1450e7e9063a3db7097 (diff)
downloadsrc-eb860592bdd395b25d606463e965b66d694dff32.tar.gz
src-eb860592bdd395b25d606463e965b66d694dff32.zip
After starting Unbound, wait for up to five seconds until unbound-control
indicates that it is up and running. PR: 184047 MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=289592
Diffstat (limited to 'etc/rc.d')
-rwxr-xr-xetc/rc.d/local_unbound21
1 files changed, 21 insertions, 0 deletions
diff --git a/etc/rc.d/local_unbound b/etc/rc.d/local_unbound
index ce3256d2f369..4bb1a0c4dcd9 100755
--- a/etc/rc.d/local_unbound
+++ b/etc/rc.d/local_unbound
@@ -17,6 +17,7 @@ rcvar="local_unbound_enable"
command="/usr/sbin/unbound"
extra_commands="anchor configtest reload setup"
start_precmd="local_unbound_prestart"
+start_postcmd="local_unbound_poststart"
reload_precmd="local_unbound_configtest"
anchor_cmd="local_unbound_anchor"
configtest_cmd="local_unbound_configtest"
@@ -90,5 +91,25 @@ local_unbound_prestart()
fi
}
+#
+# After starting, wait for Unbound to report that it is ready to avoid
+# race conditions with services which require functioning DNS.
+#
+local_unbound_poststart()
+{
+ local retry=5
+
+ echo -n "Waiting for nameserver to start..."
+ until "${command}-control" status | grep -q "is running" ; do
+ if [ $((retry -= 1)) -eq 0 ] ; then
+ echo " giving up"
+ return 1
+ fi
+ echo -n "."
+ sleep 1
+ done
+ echo " good"
+}
+
load_rc_config $name
run_rc_command "$1"