Rutorrent / Rtorrent

  multimedia

Daemon rtorrent

#!/usr/bin/env bash

# Dépendances : screen, killall et rtorrent
### BEGIN INIT INFO
# Provides: box-rtorrent
# Required-Start: $syslog $network
# Required-Stop: $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent user session
### END INIT INFO

## Début configuration ##
user="box"
## Fin configuration ##

rt_start() {
su --command="screen -dmS ${user}-rtorrent rtorrent" "${user}"
}

rt_stop() {
killall --user "${user}" screen
}

case "$1" in
start) echo "Starting rtorrent..."; rt_start
;;
stop) echo "Stopping rtorrent..."; rt_stop
;;
restart) echo "Restart rtorrent..."; rt_stop; sleep 1; rt_start
;;
*) echo "Usage: $0 {start|stop|restart}"; exit 1
;;
esac
exit 0