Lines 1-42
Link Here
|
1 |
#!/bin/sh |
1 |
#!/bin/sh |
2 |
# |
|
|
3 |
# Author: Mark Felder <feld@FreeBSD.org> |
4 |
|
2 |
|
5 |
# PROVIDE: radarr |
3 |
# PROVIDE: %%PORTNAME%% |
6 |
# REQUIRE: LOGIN |
4 |
# REQUIRE: LOGIN network |
7 |
# KEYWORD: shutdown |
5 |
# KEYWORD: shutdown |
8 |
|
6 |
# |
9 |
# Add the following lines to /etc/rc.conf to enable radarr: |
7 |
# Add the following lines to /etc/rc.conf or use sysrc to enable %%PORTNAME%% |
10 |
# radarr_enable="YES" |
8 |
# ${%%PORTNAME%%_enable="YES"} |
|
|
9 |
# Optionaly there are some other parameters |
10 |
# ${%%PORTNAME%%_user="%%USERS%%"} |
11 |
# ${%%PORTNAME%%_group="%%GROUPS%%"} |
12 |
# This stores %%PORTNAME%% data (e.g., databases, configs, logs) |
13 |
# ${%%PORTNAME%%_data_dir="/var/db/%%PORTNAME%%"} |
14 |
# This stores the PID files that daemon will use |
15 |
# ${%%PORTNAME%%_pid_dir:="/var/run/%%PORTNAME%%"} |
11 |
|
16 |
|
12 |
. /etc/rc.subr |
17 |
. /etc/rc.subr |
13 |
|
18 |
name=%%PORTNAME%% |
14 |
name="radarr" |
19 |
rcvar=%%PORTNAME%%_enable |
15 |
rcvar=radarr_enable |
|
|
16 |
|
17 |
load_rc_config $name |
20 |
load_rc_config $name |
18 |
|
21 |
|
19 |
: ${radarr_enable="NO"} |
22 |
: ${%%PORTNAME%%_enable:=NO} |
20 |
: ${radarr_user:="radarr"} |
23 |
: ${%%PORTNAME%%_user:="%%USERS%%"} |
21 |
: ${radarr_data_dir:="%%PREFIX%%/radarr"} |
24 |
: ${%%PORTNAME%%_group:="%%GROUPS%%"} |
|
|
25 |
: ${%%PORTNAME%%_exec_dir:="%%DATADIR%%"} |
26 |
: ${%%PORTNAME%%_data_dir:="/var/db/%%PORTNAME%%"} |
27 |
: ${%%PORTNAME%%_pid_dir:="/var/run/%%PORTNAME%%"} |
22 |
|
28 |
|
23 |
pidfile="${radarr_data_dir}/radarr.pid" |
29 |
pidfile="${%%PORTNAME%%_pid_dir}/${name}_daemon.pid" |
24 |
procname="%%PREFIX%%/bin/mono" |
30 |
pidfile_child="${%%PORTNAME%%_pid_dir}/${name}_child.pid" |
25 |
command="/usr/sbin/daemon" |
31 |
command="/usr/sbin/daemon" |
26 |
command_args="-f ${procname} %%DATADIR%%/Radarr.exe --nobrowser --data=${radarr_data_dir}" |
|
|
27 |
start_precmd=radarr_precmd |
28 |
|
32 |
|
29 |
radarr_precmd() |
|
|
30 |
{ |
31 |
export XDG_CONFIG_HOME=${radarr_data_dir} |
32 |
|
33 |
|
33 |
if [ ! -d ${radarr_data_dir} ]; then |
34 |
start_precmd=${name}_precmd |
34 |
install -d -o ${radarr_user} ${radarr_data_dir} |
35 |
%%PORTNAME%%_precmd() { |
35 |
fi |
36 |
if [ ! -d ${%%PORTNAME%%_data_dir} ]; then |
|
|
37 |
install -d -o ${%%PORTNAME%%_user} -g ${%%PORTNAME%%_group} ${%%PORTNAME%%_data_dir} |
38 |
fi |
39 |
if [ ! -d ${%%PORTNAME%%_pid_dir} ]; then |
40 |
install -d -o ${%%PORTNAME%%_user} -g ${%%PORTNAME%%_group} ${%%PORTNAME%%_pid_dir} |
41 |
fi |
42 |
|
43 |
chown -R ${%%PORTNAME%%_user}:${%%PORTNAME%%_group} ${%%PORTNAME%%_exec_dir} |
36 |
|
44 |
|
37 |
# Unwritable pids allow the service to start, but fails to work |
45 |
rc_flags="-r -f -p ${pidfile_child} -P ${pidfile} ${%%PORTNAME%%_exec_dir}/Radarr --data=${%%PORTNAME%%_data_dir} --nobrowser >> /dev/null 2>&1 ${rc_flags}" |
38 |
# Rare, but if you are debugging as root and accidentally start the service... |
|
|
39 |
/bin/rm -f ${pidfile} |
40 |
} |
46 |
} |
41 |
|
47 |
|
42 |
run_rc_command "$1" |
48 |
run_rc_command "$1" |
43 |
- |
|
|