#!/bin/bash # # chkconfig: - 16 84 # description: Start up seed clients for BitTorrent # # processname: btseed # config: /etc/sysconfig/bittorrent # source function library . /etc/rc.d/init.d/functions # Get network config #. /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0 # default directory for torrents to seed SEEDDIR=/var/lib/bittorrent/data # default log file SEEDLOG=/var/log/btseed.log # source the config . /etc/sysconfig/bittorrent RETVAL=0 prog="/usr/bin/btseed" btuser="torrent" btgroup="torrent" case "$1" in start) echo -n $"Starting BitTorrent seed client: " /sbin/runuser -s /bin/sh -c "$prog $SEEDOPTS $SEEDDIR" $btuser >> $SEEDLOG 2>&1 & disown -ar /bin/usleep 500000 status btseed &> /dev/null && echo_success || echo_failure RETVAL=$? if [ $RETVAL -eq 0 ]; then /bin/touch /var/lock/subsys/btseed /sbin/pidof -o %PPID -x btseed > /var/run/btseed.pid fi echo ;; stop) echo -n $"Shutting down BitTorrent seed client: " killproc $prog RETVAL=$? [ $RETVAL -eq 0 ] && /bin/rm -f /var/lock/subsys/btseed /var/run/btseed.pid echo ;; restart|reload) $0 stop $0 start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/btseed ]; then $0 stop $0 start fi RETVAL=$? ;; status) status btseed RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" exit 1 esac exit $RETVAL