summaryrefslogtreecommitdiff
path: root/rtorrent/init.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rtorrent/init.sh')
-rwxr-xr-xrtorrent/init.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/rtorrent/init.sh b/rtorrent/init.sh
new file mode 100755
index 0000000..7f36a74
--- /dev/null
+++ b/rtorrent/init.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -e
+
+RTORRENTUSER="horus"
+NAME=rtorrent
+DESC="rtorrent, a cli bittorrent client."
+
+DAEMON="/usr/bin/rtorrent"
+SCREEN="/usr/bin/screen"
+
+PIDFILE="/var/run/${NAME}.pid"
+
+START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid $RTORRENTUSER --exec $SCREEN -- -DmUS ${NAME} ${DAEMON}"
+END_OPTS="--stop --pidfile ${PIDFILE}"
+
+case "$1" in
+ start)
+ echo "Starting ${DESC}"
+ start-stop-daemon $START_OPTS
+ ;;
+ stop)
+ echo "Stopping ${DESC}"
+ start-stop-daemon $END_OPTS
+ rm -f "${PIDFILE}"
+ ;;
+ restart)
+ "$0" stop
+ rm -f "${PIDFILE}"
+ sleep 1
+ "$0" start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac