Commits

Anonymous committed bbe7f86

Initial commit

Comments (0)

Files changed (1)

+#!/bin/bash
+. /lib/lsb/init-functions
+
+# EDIT THIS VARIABLE TO THE USER THAT YOU WANT RTORRENT TO RUN AS
+USER=john
+
+case "$1" in
+  start)
+    log_daemon_msg "Starting rtorrent"
+    su $USER -c 'screen -d -m -S rtorrent rtorrent' &> /dev/null
+    if [ $? -gt 0 ]; then
+        log_failure_msg "FAILED." 
+        log_end_msg 1
+        exit 0
+    else
+        log_end_msg 0
+
+    fi
+    ;;
+  stop)
+    log_daemon_msg "Stopping rtorrent"
+    killall -w -s 2 /usr/bin/rtorrent &> /dev/null
+    if [ $? -gt 0 ]; then
+      log_failure_msg "FAILED."
+      log_end_msg 1
+    else
+      log_end_msg 0 
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"
+esac
+exit 0