Next let's look at the script that starts rtorrent:
I had to change it because I did not use su, my user already has root privileges so I'm pasting the entire script without comments, so replace what you have with code below:Code:vi /opt/etc/init.d/S99rtorrent
Hmm, so I guess that's it, let's reboot to make sure everything starts on its own, firewall applies new rules etc...Code:#!/opt/bin/bash # Do not proceed unless some apps are available. test -x /opt/bin/screen || exit 0 ##Start Configuration## # the full path to the filename where you store your rtorrent configuration config=("/opt/etc/rtorrent.conf") # set of options to run with each instance, separated by a new line options=("-n -o import=/opt/etc/rtorrent.conf") # default directory for screen, needs to be an absolute path base="/opt/share/torrent" # name of screen session srnname="rtorrent" ####################### PATH=/opt/local/bin:/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="rtorrent" NAME=rtorrent DAEMON=/opt/bin/$NAME SCRIPTNAME=/opt/etc/init.d/S99rtorrent # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 checkcnfg() { for (( i=0 ; i < ${#config[@]} ; i++ )) ; do if ! [ -r "${config[i]}" ] ; then echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate">&2 exit 3 fi session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//") if ! [ -d "${session}" ] ; then echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions">&2 exit 3 fi done } d_start() { logger "Starting." [ -d "${base}" ] && cd "${base}" stty stop undef && stty start undef screen -ls | grep .${srnname}[[:space:]] > /dev/null || screen -dm -S ${srnname} for (( i=0 ; i < ${#options[@]} ; i++ )) ; do sleep 3 screen -S ${srnname} -X screen rtorrent ${options[i]} done } d_stop() { for (( i=0 ; i < ${#config[@]} ; i++ )) ; do session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//") pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g") # make sure the pid doesn't belong to another process # skip the pid otherwise if ps | grep ${pid}.*rtorrent > /dev/null ; then kill -s INT ${pid} fi done } checkcnfg case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; restart|force-reload) echo -n "Restarting $DESC: $NAME" d_stop sleep 1 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0




Reply With Quote
