Add an option to build and run a Tox DHT Bootstrap Node.

More details at https://blog.libtoxcore.so/running-a-bootstrap-node
This commit is contained in:
Thierry Thomas 2014-10-14 20:55:19 +00:00
parent aeb64f7d23
commit 4f35543776
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=370885
5 changed files with 75 additions and 2 deletions

1
UIDs
View file

@ -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

View file

@ -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>

View file

@ -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"

View file

@ -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).

View file

@ -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