Created
September 15, 2015 18:50
-
-
Save moviuro/4a485e9aea277a0230bc to your computer and use it in GitHub Desktop.
/usr/local/etc/rtorrent
This file contains 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 | |
# | |
# $FreeBSD$ | |
# | |
# Runs as unprivileged rtorrent_user "rtorrent" | |
# Lives in "/usr/local/bin/tmux" (like "screen") because rtorrent can't daemonize itself | |
# To access rtorrent: service rtorrent attach | |
# To detach the /usr/local/bin/tmux and leave rtorrent running: Ctrl-B then D | |
# nice'd default +10 step to make it go easy on the machine | |
# Don't forget to put rtorrent_enable="YES" in your /etc/rc.conf | |
# | |
# PROVIDE: rtorrent | |
# REQUIRE: NETWORK | |
# KEYWORD: shutdown | |
. /etc/rc.subr | |
name="rtorrent" | |
rtorrent_user="rtorrent" | |
rcvar="rtorrent_enable" | |
extra_commands="attach" | |
attach_cmd="${name}_attach" | |
start_cmd="${name}_start" | |
stop_cmd="${name}_stop" | |
load_rc_config $name | |
: ${rtorrent_enable:=no} | |
rtorrent_start() { | |
su -m "$rtorrent_user" -c "/usr/local/bin/tmux new-session -d -s rtorrent 'nice /usr/local/bin/rtorrent'" | |
} | |
rtorrent_stop() { | |
su -m "$rtorrent_user" -c "/usr/local/bin/tmux send-keys -t rtorrent C-q" | |
} | |
rtorrent_attach() { | |
su -m "$rtorrent_user" -c "/usr/local/bin/tmux attach -t rtorrent" | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment