aboutsummaryrefslogtreecommitdiff
path: root/net/zerotier/files
diff options
context:
space:
mode:
authorDave Cottlehuber <dch@FreeBSD.org>2019-05-22 20:51:41 +0000
committerDave Cottlehuber <dch@FreeBSD.org>2019-05-22 20:51:41 +0000
commit7b73228cde530c812646ab74a691edb1f00e3966 (patch)
treec6258e7c2852e27bbdd3653a3ad2e8ac7c51b0af /net/zerotier/files
parentbd5373d182a77c0955f0feef652212124abaf0d9 (diff)
downloadports-7b73228cde530c812646ab74a691edb1f00e3966.tar.gz
ports-7b73228cde530c812646ab74a691edb1f00e3966.zip
net/zerotier: wait for ONLINE status before booting
- add new flag to wnable waiting for zt interface to become available - handle newer name for tap(4) in CURRENT Approved by: jrm (mentor) Differential Revision: https://reviews.freebsd.org/D18533
Notes
Notes: svn path=/head/; revision=502286
Diffstat (limited to 'net/zerotier/files')
-rw-r--r--net/zerotier/files/zerotier.in32
1 files changed, 27 insertions, 5 deletions
diff --git a/net/zerotier/files/zerotier.in b/net/zerotier/files/zerotier.in
index 87b66e7b3eef..0c2a12a7416d 100644
--- a/net/zerotier/files/zerotier.in
+++ b/net/zerotier/files/zerotier.in
@@ -12,29 +12,51 @@
#
# zerotier_enable (bool): Set to NO by default.
# Set it to YES to enable zerotier.
+# zerotier_wait_for_net (bool): Set to NO by default. Use for DHCP interfaces only
+# Set it to YES to require zerotier to wait until online
. /etc/rc.subr
name=zerotier
rcvar=zerotier_enable
+desc="peer-to-peer software-defined networking"
load_rc_config $name
-: ${zerotier_enable:="NO"}
+: ${zerotier_enable:=NO}
+: ${zerotier_wait_for_net:=NO}
-required_modules="if_tap"
+required_modules=%%ZEROTIER_IF_TAP%%
pidfile="/var/run/${name}.pid"
start_precmd="install -o root /dev/null ${pidfile}"
-command="/usr/sbin/daemon"
+command=/usr/sbin/daemon
command_args=" \
-c \
-t ${name} \
-r \
-P ${pidfile} \
%%ZEROTIER_SYSLOG%% \
- /usr/local/sbin/${name}-one"
+ %%PREFIX%%/sbin/${name}-one /var/db/${name}-one/"
+
+start_postcmd=start_postcmd
+
+start_postcmd()
+{ if checkyesno zerotier_wait_for_net; then
+ zerotier_count=5
+ until %%PREFIX%%/bin/zerotier-cli status |egrep -o ONLINE\$; do
+ warn ${name} is waiting for ONLINE status
+ sleep 2
+ zerotier_count=$((zerotier_count-1))
+ test $zerotier_count -le 0 && break
+ done
+ if test $zerotier_count -le 0; then
+ warn ${name} still not ONLINE, stopped blocking
+ else
+ warn ${name} is ONLINE
+ fi
+ fi
+}
run_rc_command "$1"
-