Created
June 14, 2014 10:36
-
-
Save Blacksly/73fc9c6488b993e6c5ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# Start/Stop rtorrent sous forme de daemon. | |
NAME=rtorrent-daemon.sh | |
SCRIPTNAME=/etc/init.d/$NAME | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
case $1 in | |
start) | |
echo "Starting rtorrent... " | |
su -l USER -c "screen -fn -dmS rtd nice -19 rtorrent" | |
echo "Terminated" | |
;; | |
stop) | |
if [ "$(ps aux | grep -e '.*rtorrent$' -c)" != 0 ]; then | |
{ | |
echo "Shutting down rtorrent... " | |
killall -r "^.*rtorrent$" | |
echo "Terminated" | |
} | |
else | |
{ | |
echo "rtorrent not yet started !" | |
echo "Terminated" | |
} | |
fi | |
;; | |
restart) | |
if [ "$(ps aux | grep -e '.*rtorrent$' -c)" != 0 ]; then | |
{ | |
echo "Shutting down rtorrent... " | |
killall -r "^.*rtorrent$" | |
echo "Starting rtorrent... " | |
su -l USER -c "screen -fn -dmS rtd nice -19 rtorrent" | |
echo "Terminated" | |
} | |
else | |
{ | |
echo "rtorrent not yet started !" | |
echo "Starting rtorrent... " | |
su -l USER -c "screen -fn -dmS rtd nice -19 rtorrent" | |
echo "Terminated" | |
} | |
fi | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 | |
exit 2 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment