Hi oleo,
I had some trouble to make the script work with transmission, because it seems that (at least here) transmissiond only seems to work in the background if called with the "-v" switch. So I changed the script to call transmissiond in a screen session:
Code:
/opt/bin/screen -d -m transmissiond -v 1 -p ${LISTENING_PORT} \
-w ${WATCHDOG} \
-u ${UPLOAD_SPEED} \
-d ${DOWNLOAD_SPEED} \
-i ${PIDFILE} ${ACTIVE}
I also changed the _fetch() function, because some download URLs have nothing to do with the torrent to download and even crash transmissiond, if special characters are in the name. I now extract the name of the download from the torrent and change some characters.
Code:
_fetch()
{
TORRENT=$(echo "${FETCH}" | sed 's|%20| |g;s|%3A|:|g;s|%2F|/|g;s|%3F|?|g;s|%3D|=|g;s|%26|\&|g;s|%5B|\[|g;s|%5D|\]|g;s|%28|(|g;s|%29|)|g;s|%7B|{|g;s|%7D|}|g;s|%25|%|g')
# echo "<p>Fetching ${TORRENT}</p>"
echo "Source: " ${SOURCE}
# wget --quiet -P ${SOURCE} "${TORRENT}" || echo "<p>wget ${TORRENT} failed</p>"
wget --quiet -O /opt/tmp/dl.torrent "${TORRENT}" || echo "<p>wget ${TORRENT} failed</p>"
# DLTARG=`btcheck /opt/tmp/dl.torrent | awk '{if($0~/cacheopen/) print substr($0,11,index($0,".")-11)".torrent"}'|sed -e 'y/\\//-/'`
DLTARG=`btlist /opt/tmp/dl.torrent | awk '{if($0~/name/)name=sprintf("%s",substr($0,index($0,":")+2))}END{print name}' | sed -e 'y/./_/' -e 'y/\\//\_/'`
echo "DLTARG=" ${DLTARG}
cp /opt/tmp/dl.torrent "${SOURCE}/${DLTARG}.torrent"
rm -f /opt/tmp/dl.torrent
}
It's only a hack, but if somebody likes it...
BTW: If I don't want to put my torrent directory into /opt/share/www, how can I access it via the web interface? And for what exactly are the directories "source" and "target"? Everything that I download, suspend or remove is in the "work" directory.
Darkstar.