aboutsummaryrefslogtreecommitdiff
path: root/news/nzbhydra2/files/nzbhydra2.in
blob: ff4a9fa85df01ee8721b027566ae0f7f051f2e23 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

# PROVIDE: nzbhydra2
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# nzbhydra2_enable (bool):	Set to NO by default.
#			Set it to YES to enable it.
# nzbhydra2_user:	The user account nzbhydra daemon runs as what
#			you want it to be. It uses '_sabnzbd' user by
#			default. Do not sets it as empty or it will run
#			as root.
# nzbhydra2_group:	The group account nzbhydra daemon runs as what
#			you want it to be. It uses 'nzbhydra2' group by
#			default. Do not sets it as empty or it will run
#			as wheel.
# nzbhydra2_dir:	Directory where nzbhydra lives.
#			Default: %%PREFIX%%/share/nzbhydra2
# nzbhydra2_data_dir:	Data directory for nzbhydra (DB, Logs, config)
#			Default: %%PREFIX%%/nzbhydra2

. /etc/rc.subr

name="nzbhydra2"
rcvar=${name}_enable

load_rc_config ${name}

: ${nzbhydra2_enable:="NO"}
: ${nzbhydra2_user:="nzbhydra2"}
: ${nzbhydra2_group:="nzbhydra2"}
: ${nzbhydra2_dir:="%%PREFIX%%/share/nzbhydra2"}
: ${nzbhydra2_data_dir:="%%PREFIX%%/nzbhydra2"}

pidfile="/var/run/nzbhydra2/nzbhydra2.pid"
command="%%PYTHON_CMD%%"
command_args="${nzbhydra2_dir}/nzbhydra2wrapperPy3.py --datafolder ${nzbhydra2_data_dir} --pidfile ${pidfile} --daemon --nobrowser --java %%JAVA%%"
start_precmd=nzbhydra2_precmd

nzbhydra2_precmd() 
{
	export XDG_CONFIG_HOME=${nzbhydra2_data_dir}

	if [ -f ${pidfile} ]; then
		rm -f ${pidfile}
		echo "Removing stale pidfile."
	elif [ ! -d ${pidfile%/*} ]; then
		install -d -o ${nzbhydra2_user} -g ${nzbhydra2_group} ${pidfile%/*}
	fi

	if [ ! -d ${nzbhydra2_data_dir} ]; then
		install -d -o ${nzbhydra2_user} -g ${nzbhydra2_group} ${nzbhydra2_data_dir}
	fi
}

run_rc_command "$1"