From 66c326b6d65388e9f1003715ad9675505f01f9d2 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 3 Jun 2022 13:05:13 +0100 Subject: added porting from alpine linux --- repo/transmission/transmission-daemon.initd | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 repo/transmission/transmission-daemon.initd (limited to 'repo/transmission/transmission-daemon.initd') diff --git a/repo/transmission/transmission-daemon.initd b/repo/transmission/transmission-daemon.initd new file mode 100644 index 0000000..0c9e366 --- /dev/null +++ b/repo/transmission/transmission-daemon.initd @@ -0,0 +1,73 @@ +#!/sbin/openrc-run +# 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/lib/transmission/config} +download_dir=${download_dir:-/var/lib/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 + 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() { + 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 $? +} + +reload() { + ebegin "Reloading transmission configuration" + start-stop-daemon --signal HUP --pidfile ${pidfile} + eend $? +} + -- cgit v1.2.1