Код: Выделить всё
#!/bin/sh
#
# rtorrent RCng startup script
# by Emanuele Cipolla (mail at emanuelecipolla dot net)
# Shamelessly ripped off the aMule startup script by Gabriele Cecchetti (amule.org forum)
#
# PROVIDE: rtorrent
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable rtorrent at startup
# rtorrent (bool): Set to "NO" by default.
# Set it to "YES" to enable rtorrent
# rtorrent_user (str): Set to user running rtorrent
# (default 'p2p')
# rtorrent_home (str): Set to home directory of user running rtorrent
# (default /home/${rtorrent_user})
. /etc/rc.subr
name="rtorrent"
rcvar=`set_rcvar`
load_rc_config $name
[ -z "$rtorrent_enable" ] && rtorrent_enable="NO"
[ -z "$rtorrent_user" ] && rtorrent_user="rtorrent"
[ -z "$rtorrent_home" ] && rtorrent_home="/80gb/www/${rtorrent_user}"
[ -z "$rtorrent_args" ] && rtorrent_args=""
required_dirs=${rtorrent_home}
required_files="${rtorrent_home}/.rtorrent.rc"
command="/usr/local/bin/rtorrent"
screen="/usr/local/bin/screen"
start_cmd="echo Starting ${name}.; su -m ${rtorrent_user} -c '${screen} -A -m -d -S rtorrent ${command} ${rtorrent_args}'"
run_rc_command "$1"