Help with init script?
I'm trying to control a BitTorrent seed from an init script.  The 
original init script (that I wrote) is in /etc/init.d/btseed.  It starts 
and stops a script that is in /usr/local/bin/btseed.  This script just 
starts btlaunchmany, which is used to seed multiple .torrents.
I couldn't get Debian Etch's btlaunchmany to work, so I installed the 
.deb for the current upstream BitTorrent that's found at 
http://download.bittorrent.com/dl/  When I run that version's 
btlaunchmany manually, it works fine.
My problem is that btlaunchmany forks a couple child processes.  When I 
try to stop my daemon, my script itself exits but the child processes 
don't.  I think I could fix this by putting a signal handler in my 
script that will kill the child processes, but I don't know how to do 
that.  I'm also not sure of what would be the best way to identify the 
child process' process ID numbers.  Perhaps ps | grep would do.
My btseed script takes no command line parameters.  Here is the code to 
start the daemon from /etc/init.d/btseed:
d_start() {
        echo -n "$NAME"
        start-stop-daemon --start --background --quiet \
        --make-pidfile --pidfile "$PIDFILE" \
        --chuid nobody \
        --exec $DAEMON -- $DAEMONOPTS
}
Here is the code to stop it:
d_stop() {
start-stop-daemon --stop --oknodo --quiet --pidfile "$PIDFILE"
}
I have experimented with giving --signal to start-stop-daemon to try 
giving different signals to btseed, but nothing seemed to help.
Here is the btseed script:
#!/bin/sh
/usr/bin/btlaunchmany.py --max_upload_rate 128 \
 --save_in /var/bittorrent/torrentfiles \
 --torrent_dir /var/bittorrent/active \
 --minport 50000 \
 --maxport 51000 \
 --data_dir /var/bittorrent/data | /bin/bzip2 > 
/var/bittorrent/logs/bt.log.bz2
The reason I didn't just run btlaunchmany.py directly from the init 
script is that I need to pipe its output through bzip2 and redirect it 
to a file.  I wasn't clear on how I could do that from the 
start-stop-daemon command line.
Compressing the log is necessary because btlaunchmany.py's output is 
quite verbose, and will fill a filesystem quickly.
The nonstandard port numbers are an effort to work around ISPs who 
filter BitTorrent traffic.  This doesn't always work, but probably does 
in some cases.  The BitTorrent protocol itself handles the nonstandard 
port numbers without any trouble.
Thanks for any help you can give me.
Rippit
--
Rippit the Ogg Frog
rippit@oggfrog.com
http://www.oggfrog.com/
  Software isn't the only thing that should be free.
        Music should be too, as it once was.
Reply to: