aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Thomas <thierry@FreeBSD.org>2014-10-14 20:55:19 +0000
committerThierry Thomas <thierry@FreeBSD.org>2014-10-14 20:55:19 +0000
commit4f355437767f7b451b8de02678e65b17dec4ed1d (patch)
treeb12fa51dfd6f3ea4e53680f529107142c5070312
parentaeb64f7d2342846ceff000c623b3aef62fda7af8 (diff)
downloadports-4f355437767f7b451b8de02678e65b17dec4ed1d.tar.gz
ports-4f355437767f7b451b8de02678e65b17dec4ed1d.zip
Add an option to build and run a Tox DHT Bootstrap Node.
Notes
Notes: svn path=/head/; revision=370885
-rw-r--r--UIDs1
-rw-r--r--net-im/tox/Makefile25
-rw-r--r--net-im/tox/files/tox-bootstrapd.in42
-rw-r--r--net-im/tox/pkg-message.daemon4
-rw-r--r--net-im/tox/pkg-plist5
5 files changed, 75 insertions, 2 deletions
diff --git a/UIDs b/UIDs
index 84d94d50efa7..5faba5471b5f 100644
--- a/UIDs
+++ b/UIDs
@@ -307,4 +307,5 @@ tvheadend:*:984:984::0:0:TV Headend:/usr/local/etc/tvheadend:/bin/sh
puppetdb:*:985:985::0:0:PuppetDB Daemon pseudo-user:/nonexistent:/usr/sbin/nologin
kamailio:*:986:986::0:0:kamailio daemon:/nonexistent:/usr/sbin/nologin
spark:*:987:987::0:0:Apache Spark user:/nonexistent:/usr/sbin/nologin
+toxdht:*:988:65534::0:0:Tox DHT bootstrap user:/nonexistent:/usr/sbin/nologin
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
diff --git a/net-im/tox/Makefile b/net-im/tox/Makefile
index fec8c01a1e61..d94711274075 100644
--- a/net-im/tox/Makefile
+++ b/net-im/tox/Makefile
@@ -3,6 +3,7 @@
PORTNAME= toxcore
PORTVERSION= 0.141012
+PORTREVISION= 1
CATEGORIES= net-im net-p2p
MAINTAINER= thierry@FreeBSD.org
@@ -31,6 +32,7 @@ USE_LDCONFIG= yes
PATHFIX_MAKEFILEIN= Makefile.am
INSTALL_TARGET= install-strip
+OPTIONS_DEFINE= DAEMON
OPTIONS_RADIO= CRYPTO
OPTIONS_RADIO_CRYPTO= SODIUM NACL
OPTIONS_DEFAULT= SODIUM
@@ -41,9 +43,14 @@ SODIUM_LIB_DEPENDS= libsodium.so:${PORTSDIR}/security/libsodium
NACL_DESC= Prefer NaCl
NACL_CONFIGURE_ENABLE= nacl
+NACL_CONFIGURE_ON= --with-nacl-libs=${LOCALBASE}/lib
NACL_BUILD_DEPENDS= ${LOCALBASE}/lib/libnacl.a:${PORTSDIR}/security/nacl
NACL_RUN_DEPENDS= ${LOCALBASE}/lib/libnacl.a:${PORTSDIR}/security/nacl
+DAEMON_DESC= Bootstrap daemon
+DAEMON_CONFIGURE_ENABLE=daemon
+DAEMON_LIB_DEPENDS= libconfig.so:${PORTSDIR}/devel/libconfig
+
.include <bsd.port.options.mk>
.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1000000
@@ -51,11 +58,25 @@ USE_GCC= yes
BROKEN_i386= '__stack_chk_fail_local' isn't defined
.endif
-.if ${PORT_OPTIONS:MNACL}
-CONFIGURE_ARGS+= --with-nacl-libs=${LOCALBASE}/lib
+.if ${PORT_OPTIONS:MDAEMON}
+USERS= toxdht
+USE_RC_SUBR= tox-bootstrapd
+SUB_LIST= TOXDHT=${USERS}
+PLIST_SUB+= TOXDHT=${USERS}
+KEYS_DIR= /var/lib/tox-bootstrapd
+PID_DIR= /var/run/tox-bootstrapd
+PKGMESSAGE= ${PKGDIR}/pkg-message.daemon
.endif
pre-configure:
${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' ${WRKSRC}/configure.ac
+post-install:
+.if ${PORT_OPTIONS:MDAEMON}
+ ${INSTALL_DATA} ${WRKSRC}/other/bootstrap_daemon/tox-bootstrapd.conf \
+ ${STAGEDIR}${PREFIX}/etc/tox-bootstrapd.conf.sample
+ ${MKDIR} ${STAGEDIR}${KEYS_DIR}
+ ${MKDIR} ${STAGEDIR}${PID_DIR}
+.endif
+
.include <bsd.port.mk>
diff --git a/net-im/tox/files/tox-bootstrapd.in b/net-im/tox/files/tox-bootstrapd.in
new file mode 100644
index 000000000000..8c70b89e38cd
--- /dev/null
+++ b/net-im/tox/files/tox-bootstrapd.in
@@ -0,0 +1,42 @@
+#! /bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: tox_bootstrapd
+# REQUIRE: NETWORKING DAEMON
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable `tox-bootstrapd':
+#
+#tox_bootstrapd_enable="YES"
+#
+
+. /etc/rc.subr
+
+name="tox_bootstrapd"
+rcvar=tox_bootstrapd_enable
+
+# read settings, set default values
+load_rc_config "${name}"
+: ${tox_bootstrapd_enable="NO"}
+
+required_files=${tox_bootstrapd_config:="%%PREFIX%%/etc/tox-bootstrapd.conf"}
+_pidprefix="/var/run/tox-bootstrapd"
+pidfile=${tox_bootstrapd_pidfile:="$_pidprefix/tox-bootstrapd.pid"}
+long_name="Tox DHT bootstrap daemon."
+tox_bootstrapd_user="%%TOXDHT%%"
+command="%%PREFIX%%/bin/tox-bootstrapd"
+command_args="${tox_bootstrapd_config}"
+
+stop_cmd=${name}_stop
+
+# Cannot use the regular stop() because the daemon forks
+tox_bootstrapd_stop() {
+ [ -f $pidfile ] || (echo "$name not running?"; exit 1)
+ echo "Stopping $long_name"
+ kill `ps ax | grep $command | grep -v grep | awk '{print $1}'`
+ rm -f $pidfile
+}
+
+run_rc_command "$1"
diff --git a/net-im/tox/pkg-message.daemon b/net-im/tox/pkg-message.daemon
new file mode 100644
index 000000000000..e5e85be67b94
--- /dev/null
+++ b/net-im/tox/pkg-message.daemon
@@ -0,0 +1,4 @@
+
+Warning: your public key will be logged at the level INFO. Check that your
+/etc/syslog is configured to log these messages if you need it (to publicize
+it).
diff --git a/net-im/tox/pkg-plist b/net-im/tox/pkg-plist
index 791e91e2d5a7..cc5877736339 100644
--- a/net-im/tox/pkg-plist
+++ b/net-im/tox/pkg-plist
@@ -1,4 +1,6 @@
bin/DHT_bootstrap
+%%DAEMON%%bin/tox-bootstrapd
+%%DAEMON%%@sample etc/tox-bootstrapd.conf.sample
include/tox/tox.h
include/tox/toxav.h
include/tox/toxdns.h
@@ -21,3 +23,6 @@ lib/libtoxencryptsave.a
%%SODIUM%%lib/libtoxencryptsave.so.0.0.0
libdata/pkgconfig/libtoxav.pc
libdata/pkgconfig/libtoxcore.pc
+%%DAEMON%%@dir(%%TOXDHT%%,nobody,755) /var/run/tox-bootstrapd
+%%DAEMON%%@dir(%%TOXDHT%%,nobody,700) /var/lib/tox-bootstrapd
+%%DAEMON%%@dir /var/lib