aboutsummaryrefslogtreecommitdiff
path: root/net-p2p/transmission-cli/files/transmission.in
blob: bb1070bae7da52d5cfa1e89d46daecb4b5abaf9b (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: transmission
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable this service:
#
# transmission_enable:	     Set to NO by default. Set it to YES to enable it.
# transmission_watch_dir:    Directory for torrent files to download
#			     automatically. Off by default unless you add
#			     a path.
# transmission_conf_dir:     Directory where transmission configuration
#			     data is stored.
#			     Default: %%PREFIX%%/etc/transmission/home
# transmission_download_dir: Directory to store downloaded data.
#			     Default: %%PREFIX%%/etc/transmission/home/Downloads
# transmission_user:	     The user account transmission daemon runs as what
#			     you want it to be. It uses 'transmission' user by
#			     default.
# transmission_web_home:     Use alternative directory for the web interface
#			     files, such as javascript, html and graphics.
# transmission_chown:	     By default, transmission checks and fixes the
#			     permissions for its home directory.  If this
#			     causes problems, set this variable to no.
#

. /etc/rc.subr

name=transmission
rcvar=transmission_enable

load_rc_config $name

: ${transmission_enable:=NO}
: ${transmission_conf_dir=%%PREFIX%%/etc/transmission/home}
: ${transmission_download_dir=%%PREFIX%%/etc/transmission/home/Downloads}
: ${transmission_user:=transmission}
transmission_group=${transmission_group:-$transmission_user}
: ${transmission_chown:=yes}

command=%%PREFIX%%/bin/transmission-daemon
pidfile=/var/run/transmission/daemon.pid
extra_commands=reload
start_precmd=transmission_prestart

transmission_flags=" \
	${transmission_watch_dir:+-c ${transmission_watch_dir}} \
	${transmission_conf_dir:+-g ${transmission_conf_dir}} \
	${transmission_download_dir:+-w ${transmission_download_dir}} \
	${pidfile:+-x $pidfile} \
	${transmission_flags}"

transmission_prestart()
{
	install -d -o $transmission_user ${pidfile%/*}
	if checkyesno transmission_chown; then
		mkdir -p $transmission_conf_dir $transmission_download_dir
		chown $transmission_user:$transmission_group $transmission_download_dir
		chown -R $transmission_user:$transmission_group $transmission_conf_dir
		chgrp $transmission_group $transmission_conf_dir
		chmod 750 $transmission_conf_dir
	fi
	if [ -n "$transmission_web_home" ]; then
		TRANSMISSION_WEB_HOME=$transmission_web_home
		export TRANSMISSION_WEB_HOME
	fi
}

# Unfortunately there was a typo in a previous version, which may have
# left some people with /var/run/transmission/damon.pid .  Deal with
# this for a few months at least, until everyone will have restarted
# transmission
if [ ! -f $pidfile -a -f /var/run/transmission/damon.pid ]; then
	pidfile=/var/run/transmission/damon.pid
fi

run_rc_command $1