forked from genba/freenas-plugins
/
couchpotato.in
executable file
·51 lines (44 loc) · 1.52 KB
/
couchpotato.in
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
#!/bin/sh
#
# PROVIDE: %%PORTNAME%%
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# %%PORTNAME%%_enable (bool): Set to NO by default.
# Set it to YES to enable it.
# %%PORTNAME%%_user: The user account %%PORTNAME%% daemon runs as what
# you want it to be. It uses '%%USERS%%' user by
# default. Do not sets it as empty or it will run
# as root.
# %%PORTNAME%%_group: The group account %%PORTNAME%% daemon runs as what
# you want it to be. It uses '%%GROUPS%%' group by
# default. Do not sets it as empty or it will run
# as wheel.
# %%PORTNAME%%_data_dir: Directory where %%PORTNAME%% configuration
# data is stored.
# Default: /var/db/%%PORTNAME%%
. /etc/rc.subr
name="%%PORTNAME%%"
rcvar="${name}_enable"
load_rc_config ${name}
: ${%%PORTNAME%%_enable:="NO"}
: ${%%PORTNAME%%_user:="%%USERS%%"}
: ${%%PORTNAME%%_group:="%%GROUPS%%"}
: ${%%PORTNAME%%_data_dir:="/var/db/%%PORTNAME%%"}
pidfile="/var/run/%%PORTNAME%%/%%PORTNAME%%.pid"
command="%%PYTHON_CMD%%"
command_args="%%DATADIR%%/CouchPotatoServer/CouchPotato.py --data_dir ${couchpotato_data_dir} --pid_file ${pidfile} --daemon"
start_precmd="%%PORTNAME%%_prestart"
%%PORTNAME%%_prestart() {
export LC_CTYPE="UTF-8"
if [ ! -d ${pidfile%/*} ]; then
install -d -o ${%%PORTNAME%%_user} -g ${%%PORTNAME%%_group} ${pidfile%/*}
fi
if [ ! -d ${%%PORTNAME%%_data_dir} ]; then
install -d -o ${%%PORTNAME%%_user} -g ${%%PORTNAME%%_group} ${%%PORTNAME%%_data_dir}
fi
}
run_rc_command "$1"