diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-05-21 09:21:57 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-05-21 09:33:30 +0000 |
commit | 52268079a47baae6e6fa5924acf71e88e12d2d12 (patch) | |
tree | 988fc79dda1821d9becd37fd03e7951a7dc175a6 /main/transmission/transmission-daemon.initd | |
parent | 2b0f7775a6db5bd4b175b649fa10afdef2d78f01 (diff) | |
download | aports-52268079a47baae6e6fa5924acf71e88e12d2d12.tar.bz2 aports-52268079a47baae6e6fa5924acf71e88e12d2d12.tar.xz |
main/transmission: upgrade to 2.52 and sync init.d script
Copy init.d script from gentoo.
fixes #1119
Diffstat (limited to 'main/transmission/transmission-daemon.initd')
-rw-r--r-- | main/transmission/transmission-daemon.initd | 73 |
1 files changed, 62 insertions, 11 deletions
diff --git a/main/transmission/transmission-daemon.initd b/main/transmission/transmission-daemon.initd index 4f0acd24f0..58d8d11a56 100644 --- a/main/transmission/transmission-daemon.initd +++ b/main/transmission/transmission-daemon.initd @@ -1,22 +1,73 @@ #!/sbin/runscript +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-p2p/transmission/files/transmission-daemon.initd.8,v 1.2 2011/12/04 10:35:07 swegener Exp $ + +extra_started_commands="reload" +description="Transmission is a fast, easy and free bittorrent client" +description_start="Start transmission-daemon server and web interface" +description_stop="Stop transmission-daemon server and web interface" +description_reload="Reload transmission-daemon settings" + +rundir=${rundir:-/var/run/transmission} +pidfile=${pidfile:-${rundir}/transmission.pid} +config_dir=${config_dir:-/var/transmission/config} +download_dir=${download_dir:-/var/transmission/downloads} +logfile=${logfile:-/var/log/transmission/transmission.log} +runas_user=${runas_user:-transmission:transmission} + +SSD_OPTIONS="" + +# compatibility for upgraders +TRANSMISSION_OPTIONS=${TRANSMISSION_OPTIONS:-$TD_OPTS} depend() { - need net + need net after firewall } +check_config() { + if [ ! -d "${rundir}" ]; then + mkdir "${rundir}" + if [ -n "${runas_user}" ]; then + chown -R ${runas_user} "${rundir}" + fi + fi + + # In case no config directory option passed use default + if ! $(echo ${TRANSMISSION_OPTIONS} | grep -q -e '\B-g' -e '\B--config-dir'); then + TRANSMISSION_OPTIONS="${TRANSMISSION_OPTIONS} --config-dir ${config_dir}" + # put download dir location on first run (and take it from config later) + if [ ! -f ${config_dir}/settings.json ]; then + TRANSMISSION_OPTIONS="${TRANSMISSION_OPTIONS} --download-dir ${download_dir}" + fi + fi + + if [ -n "${runas_user}" ]; then + SSD_OPTIONS="${SSD_OPTIONS} --user ${runas_user}" + fi +} + start() { - ebegin "Starting transmission-daemon" - start-stop-daemon --start --quiet --background --make-pidfile \ - --user transmission:transmission \ - --pidfile /var/run/transmission-daemon.pid \ - --exec /usr/bin/transmission-daemon -- ${TD_OPTS} - eend $? + check_config + + ebegin "Starting transmission daemon" + start-stop-daemon --start --quiet --pidfile ${pidfile} ${SSD_OPTIONS} \ + --exec /usr/bin/transmission-daemon -- --pid-file ${pidfile} \ + $(test ${logfile} != "syslog" && echo --logfile ${logfile}) \ + ${TRANSMISSION_OPTIONS} + eend $? } stop() { - ebegin "Stopping transmission-daemon" - start-stop-daemon --stop --quiet \ - --pidfile /var/run/transmission-daemon.pid \ - eend $? + ebegin "Stopping transmission daemon" + start-stop-daemon --stop --quiet --retry TERM/45/QUIT/15 --pidfile ${pidfile} + eend $? } + +reload() { + ebegin "Reloading transmission configuration" + start-stop-daemon --signal HUP --pidfile ${pidfile} + eend $? +} + |