blob: 67c505852f3cb85657c62ea7f14505c16359640e (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: deluged
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# MANDATORY:
#
# deluged_enable (bool): Set to NO by default.
# Set it to YES to enable deluged.
#
# deluged_user (str): The UNPRIVILEGED user to run as
#
# OPTIONAL:
#
# deluged_flags (str): Set as needed
# See deluged(1) for more information
#
# deluged_confdir (path): Set to /home/$deluged_user/.config/deluge
# by default
#
# deluged_loglevel (str): Set to "error" by default
#
# deluged_logfile (path): Set to /var/tmp/deluged.log by default
. /etc/rc.subr
name="deluged"
rcvar=deluged_enable
command=%%PREFIX%%/bin/${name}
command_interpreter=%%PYTHON_CMD%%
pidfile=/var/run/${name}/pid
start_precmd=${name}_prestart
stop_postcmd=${name}_poststop
deluged_prestart()
{
if [ "$deluged_user" = 'asjklasdfjklasdf' ]; then
err 1 "You must set deluged_user to a real, unprivileged user"
fi
if [ ! -d "/var/run/${name}" ]; then
if [ -e "/var/run/${name}" ]; then
unlink /var/run/${name}
fi
mkdir -p /var/run/${name}
fi
chmod 0755 /var/run/${name}
chown -R $deluged_user /var/run/${name}
}
deluged_poststop()
{
[ -e "$pidfile" ] && unlink $pidfile
[ -d "${pidfile%/pid}" ] && rmdir ${pidfile%/pid}
[ -e "$deluged_logfile" -a ! -s "$deluged_logfile" ] &&
unlink $deluged_logfile
}
load_rc_config $name
: ${deluged_enable:="NO"}
: ${deluged_user:="asjklasdfjklasdf"}
: ${deluged_confdir:="/home/${deluged_user}/.config/deluge"}
: ${deluged_loglevel:="error"}
: ${deluged_logfile:="/var/tmp/${name}.log"}
required_dirs="$deluged_confdir"
command_args="-c $required_dirs -L $deluged_loglevel -l $deluged_logfile -P $pidfile"
run_rc_command "$1"
|