daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Jan 26th, 2015 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #/etc/init.d/torrent
  3.  
  4. ### BEGIN INIT INFO
  5. # Provides:          rtorrent_service
  6. # Required-Start:    $local_fs $remote_fs $network $syslog $netdaemons
  7. # Required-Stop:     $local_fs $remote_fs $network $syslog
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Description:       rtorrent tmux init.d script
  11. ### END INIT INFO
  12.  
  13. USER=box
  14. GROUP=www-data
  15.  
  16. # OPTIONS=
  17. SESS_NAME=rtorrent
  18. CONFIG=/home/$USER/.rtorrent.rc
  19. OPTIONS="-n -O import=$CONFIG"
  20.  
  21. case "$1" in
  22.   start)
  23.     sudo -u $USER -g $USER tmux new-session -d -s $SESS_NAME -n rtorrent rtorrent # $OPTIONS
  24.     if [ $? -ne 0 ] ; then
  25.       echo "RTorrent is running."
  26.     else
  27.       echo "RTorrent is started."
  28.     fi
  29.     ;;
  30.  
  31.   stop)
  32.     PID=$(pidof rtorrent)
  33.     if [ "$PID" != "" ] ; then
  34.       kill -s INT $PID
  35.       echo "RTorrent now stopped."
  36.     else
  37.       echo "RTorrent is NOT running."
  38.     fi
  39.     ;;
  40.  
  41.   up)
  42.     if [ -e $PIDFILE ] ; then
  43.       sudo -u $USER tmux at -t $SESS_NAME
  44.     fi
  45.     ;;
  46.  
  47.   restart)
  48.     "$0" stop
  49.     sleep 1
  50.     "$0" start
  51.     exit 1
  52.     ;;
  53.  
  54.   *)
  55.     echo "Usage: $0 start|stop|up|restart"
  56.     exit 1
  57.     ;;
  58.  
  59. esac
  60.  
  61. exit 0
RAW Paste Data
Top