aboutsummaryrefslogtreecommitdiff
path: root/net-im/tox/files/tox-bootstrapd.in
blob: 6563bcb5d0d9951804dfc7489411a67af8f1a8e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /bin/sh

# 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="--config ${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"