Skip to content

Instantly share code, notes, and snippets.

@wisicn
Forked from wangyan/rtorrent.sh
Last active August 29, 2015 14:07
Show Gist options
  • Save wisicn/741b62f703a28ae38bb2 to your computer and use it in GitHub Desktop.
Save wisicn/741b62f703a28ae38bb2 to your computer and use it in GitHub Desktop.
#!/bin/sh
case "$1" in
start)
echo -n "Starting rtorrent"
su - root -c "screen -A -m -d -S rtorrent /usr/local/bin/rtorrent" &
echo "."
;;
stop)
echo -n "Stopping rtorrent"
ppid=`ps ax | grep "/usr/local/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
echo "."
;;
restart)
echo -n "Restarting rtorrent"
ppid=`ps ax | grep "/usr/local/bin/rtorrent" | grep -v grep | grep -v screen | awk '{ print $1 }'`
kill ${ppid}
sleep 1
su - root -c "screen -A -m -d -S rtorrent /usr/local/bin/rtorrent" &
echo "."
;;
*)
echo "Usage: {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment