Commit 9f0a3d2e authored by Otto Modinos's avatar Otto Modinos
Browse files

community/transmission: import newest init.d from Gentoo

parent 29327b78
......@@ -3,7 +3,7 @@
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=transmission
pkgver=3.00
pkgrel=6
pkgrel=7
pkgdesc="Lightweight GTK BitTorrent client"
url="https://transmissionbt.com/"
install="transmission-daemon.pre-install transmission-daemon.post-upgrade"
......
#!/sbin/openrc-run
# Copyright 1999-2011 Gentoo Foundation
# Copyright 1999-2016 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 $
command="/usr/bin/transmission-daemon"
extra_started_commands="reload"
description="Transmission is a fast, easy and free bittorrent client"
description_start="Start transmission-daemon server and web interface"
......@@ -16,58 +16,34 @@ download_dir=${download_dir:-/var/lib/transmission/downloads}
logfile=${logfile:-/var/log/transmission/transmission.log}
runas_user=${runas_user:-transmission:transmission}
SSD_OPTIONS=""
retry="TERM/45/QUIT/15"
# compatibility for upgraders
TRANSMISSION_OPTIONS=${TRANSMISSION_OPTIONS:-$TD_OPTS}
start_pre() {
command_args="--config-dir ${config_dir} --pid-file ${pidfile}"
command_user="${runas_user}"
depend() {
need net
after firewall
}
# Call mkdir -p in case parent dirs are missing
mkdir -p "${rundir}" "${config_dir}" "${download_dir}"
check_config() {
if [ ! -d "${rundir}" ]; then
mkdir "${rundir}"
if [ -n "${runas_user}" ]; then
chown -R ${runas_user} "${rundir}"
fi
fi
# Call checkpath to fixup permissions
checkpath -d -o "${runas_user}" "${rundir}" "${config_dir}" "${download_dir}" || return
# 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
if [ ! -e "${config_dir}/settings.json" ]; then
# Only set download dir if settings don't exist
# https://bugs.gentoo.org/576640
command_args="${command_args} --download-dir ${download_dir}"
fi
if [ -n "${runas_user}" ]; then
SSD_OPTIONS="${SSD_OPTIONS} --user ${runas_user}"
if [ "${logfile}" != syslog ]; then
checkpath -d -o "${runas_user}" /var/log/transmission || return
command_args="${command_args} --logfile ${logfile}"
fi
}
start() {
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 --retry TERM/45/QUIT/15 --pidfile ${pidfile}
eend $?
command_args="${command_args} ${TRANSMISSION_OPTIONS}"
}
reload() {
ebegin "Reloading transmission configuration"
start-stop-daemon --signal HUP --pidfile ${pidfile}
ebegin "Reloading ${RC_SVCNAME}"
start-stop-daemon --signal HUP --exec "${command}" --pidfile "${pidfile}"
eend $?
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment