freebsd-ports/net-p2p/deluge/files/deluged.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

81 lines
1.7 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: deluged
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# MANDATORY:
#
# deluged_enable (bool): Set to NO by default.
# Set it to YES to enable deluged.
#
# deluged_user (str): The UNPRIVILEGED user to run as
#
# OPTIONAL:
#
# deluged_flags (str): Set as needed
# See deluged(1) for more information
#
# deluged_confdir (path): Set to /home/$deluged_user/.config/deluge
# by default
#
# deluged_loglevel (str): Set to "error" by default
#
# deluged_logfile (path): Set to /var/tmp/deluged.log by default
. /etc/rc.subr
name="deluged"
rcvar=deluged_enable
command=%%PREFIX%%/bin/${name}
command_interpreter=%%PYTHON_CMD%%
pidfile=/var/run/${name}/pid
start_precmd=${name}_prestart
stop_postcmd=${name}_poststop
deluged_prestart()
{
if [ "$deluged_user" = 'asjklasdfjklasdf' ]; then
err 1 "You must set deluged_user to a real, unprivileged user"
fi
if [ ! -d "/var/run/${name}" ]; then
if [ -e "/var/run/${name}" ]; then
unlink /var/run/${name}
fi
mkdir -p /var/run/${name}
fi
chmod 0755 /var/run/${name}
chown -R $deluged_user /var/run/${name}
}
deluged_poststop()
{
[ -e "$pidfile" ] && unlink $pidfile
[ -d "${pidfile%/pid}" ] && rmdir ${pidfile%/pid}
[ -e "$deluged_logfile" -a ! -s "$deluged_logfile" ] &&
unlink $deluged_logfile
}
load_rc_config $name
: ${deluged_enable:="NO"}
: ${deluged_user:="asjklasdfjklasdf"}
: ${deluged_confdir:="/home/${deluged_user}/.config/deluge"}
: ${deluged_loglevel:="error"}
: ${deluged_logfile:="/var/tmp/${name}.log"}
required_dirs="$deluged_confdir"
command_args="-c $required_dirs -L $deluged_loglevel -l $deluged_logfile -P $pidfile"
run_rc_command "$1"