summaryrefslogtreecommitdiff
path: root/net-p2p/sonarr/files/sonarr.in
blob: ca87b8ba3bb477d3fa0cf3e9dfb4c934c82f1efa (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
#!/bin/sh
#
# Author: Mark Felder <feld@FreeBSD.org>

# PROVIDE: sonarr
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable sonarr:
# sonarr_enable="YES"

. /etc/rc.subr

name="sonarr"
rcvar=sonarr_enable

load_rc_config $name

: ${sonarr_enable="NO"}
: ${sonarr_user:="sonarr"}
: ${sonarr_data_dir:="%%PREFIX%%/sonarr"}

pidfile="${sonarr_data_dir}/sonarr.pid"
procname="%%PREFIX%%/bin/mono"
command="/usr/sbin/daemon"
command_args="-f ${procname} %%DATADIR%%/Sonarr.exe --nobrowser --data=${sonarr_data_dir}"
start_precmd=sonarr_precmd

sonarr_precmd()
{
	export XDG_CONFIG_HOME=${sonarr_data_dir}

	if [ ! -d ${sonarr_data_dir} ]; then
		install -d -o ${sonarr_user} ${sonarr_data_dir}
	fi

	# Unwritable pids allow the service to start, but fails to work
	# Rare, but if you are debugging as root and accidentally start the service...
	/bin/rm -f ${pidfile}
}

run_rc_command "$1"