Skip to content

Instantly share code, notes, and snippets.

@thwarted
Created September 19, 2014 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thwarted/d576e1febab19f9e8bcd to your computer and use it in GitHub Desktop.
Save thwarted/d576e1febab19f9e8bcd to your computer and use it in GitHub Desktop.
control script for transmission; you'll need to roll your own settings.json
#!/bin/bash
TRHOME=$( readlink -f $( dirname $0 ) )
# mkdir -p complete config incomplete logs torrents
PIDFILE=$TRHOME/logs/transmission.pid
dostart() {
cd $TRHOME
transmission-daemon \
--config-dir $TRHOME/config \
-ep \
--peerport 51413 \
--allowed '172.27.*' \
--logfile $TRHOME/logs/transmission.log \
--pid-file $PIDFILE \
--log-info \
--watch-dir $TRHOME/torrents/ \
--incomplete-dir $TRHOME/incomplete \
--download-dir $TRHOME/complete/
}
dostop() {
kill $( cat $PIDFILE )
}
dostatus() {
if [ -s $PIDFILE ]; then
pid=$( cat $PIDFILE )
if test -e /proc/$pid/cmdline && grep -sq transmission /proc/$pid/cmdline; then
echo "running (pid $pid)"
else
echo "not running (pid file found)"
fi
else
echo "not running"
fi
}
case "$1" in
start )
dostart
;;
stop )
dostop
;;
restart )
stop && start
;;
status )
dostatus
;;
* )
echo "Usage: $0 [ start | stop | status | restart ]" >&2
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment