Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #/etc/init.d/torrent
- ### BEGIN INIT INFO
- # Provides: rtorrent_service
- # Required-Start: $local_fs $remote_fs $network $syslog $netdaemons
- # Required-Stop: $local_fs $remote_fs $network $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Description: rtorrent tmux init.d script
- ### END INIT INFO
- USER=box
- GROUP=www-data
- # OPTIONS=
- SESS_NAME=rtorrent
- CONFIG=/home/$USER/.rtorrent.rc
- OPTIONS="-n -O import=$CONFIG"
- case "$1" in
- start)
- sudo -u $USER -g $USER tmux new-session -d -s $SESS_NAME -n rtorrent rtorrent # $OPTIONS
- if [ $? -ne 0 ] ; then
- echo "RTorrent is running."
- else
- echo "RTorrent is started."
- fi
- ;;
- stop)
- PID=$(pidof rtorrent)
- if [ "$PID" != "" ] ; then
- kill -s INT $PID
- echo "RTorrent now stopped."
- else
- echo "RTorrent is NOT running."
- fi
- ;;
- up)
- if [ -e $PIDFILE ] ; then
- sudo -u $USER tmux at -t $SESS_NAME
- fi
- ;;
- restart)
- "$0" stop
- sleep 1
- "$0" start
- exit 1
- ;;
- *)
- echo "Usage: $0 start|stop|up|restart"
- exit 1
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement