I had already one init.d script for rtorrent which was using screen ( here ). Well, almost a year ago, I "discovered" tmux, as a good alternative for screen. In fact I found that tmux is a little be more stable, and have some extra fancy feature. Of course you have to have a good rc file to get much out of it. Read more about tmux here: So, the new "improved" init.d script: #!/bin/bash ### BEGIN INIT INFO# Provides: rtorrent# Required-Start: # X-Start-Before: # Required-Stop:# Default-Start: 2 # Default-Stop: 1# Short-Description: run rtorrent as a given user in a tmux. # Description: run rtorrent as a given user in a tmux.### END INIT INFO#Setup#The user who will run the client. This user must have an rtorrentrc in her home dir.USER=username#You don't really have to change these...SESS_NAME=rtorrentcase "$1" instart)sudo -u $USER tmux new-session -d -s rtorrent $SESS_NAMEif [ $? -ne 0 ] ; thenecho "RTorrent is running."elseecho "RTorrent is started."fi;;stop)PID=$(pidof rtorrent)if [ "$PID" != "" ] ; thenkill $PIDecho "RTorrent now stopped."elseecho "RTorrent is NOT running."fi;;bring-front)if [ -e $PIDFILE ] ; thensudo -u $USER tmux at -t $SESS_NAMEfi;;*)echo "Usage: $0 start|stop|bring-front";;esacSome hints (for ubuntu / debian users, others please refer to http://bit.ly/THMNaH):
|
Bash & Python >