Page 1 of 1

FreeBSD Init Scripts

Posted: Thu Apr 01, 2010 6:45 am
by .faust
I put them in Wiki
FreeBSD Init Scripts

Re: FreeBSD Init Scripts

Posted: Thu Apr 01, 2010 10:57 am
by Cas
Thanks :D

Re: FreeBSD Init Scripts

Posted: Tue Apr 06, 2010 5:48 pm
by Spadge
Awesome stuff, thanks.

Just a couple of changes I've made to mine, don't know if you're interested ...
#!/bin/sh
#
# deluged RCng startup script
# created by: R.S.A. aka .faust
# mail: rsa dot aka dot f at gmail dot com
#

# PROVIDE: deluged
# REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf.local or /etc/rc.conf to enable deluged at startup
# deluged_enable="YES"
#
# pidfile (str): Specify the full path to the PID file
# log (str): Specify the full path to the LOG file
# delugew_user (str): Set to user running deluge-web
# cfg_dir (str): Specify the full path to directory with deluge config files
#
# Warning! Rights to folders and files must be "rwx" for the user under which the run deluge

. /etc/rc.subr

name="deluged"
rcvar=`set_rcvar`

load_rc_config $name
deluged_enable=${deluged_enable:=NO}

log=""
loglevel="error" # none, info, warning, error, critical, debug
pidfile=""
cfg_dir=""
deluged_user=""

required_dirs=${cfg_dir}

command_interpreter="/usr/local/bin/python"
command="/usr/local/bin/${name}"
start_cmd="${name}_start"

deluged_start()
{
if [ ! -f "${pidfile}" ]; then
su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}"
echo "Starting ${name}."
else
GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluged/ && !/awk/ && !/sh/ {print $2}'`
PIDFROMFILE=`cat ${pidfile}`
if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then
echo "${name} already running with PID: ${PIDFROMFILE} ?"
echo "Remove ${pidfile} manually if needed."
else
rm -f ${pidfile}
su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -L ${loglevel} -l ${log} -P ${pidfile} > /dev/null 2>&1 &"
echo "Starting ${name}."
fi
fi
}


run_rc_command "$1"
So to sum up, I added a variable $loglevel and pass it to -L in the startup line, and added ' > /dev/null 2>&1 &' to the end of the startup line to prevent deluged from spamming up your console when something goes wrong.

Re: FreeBSD Init Scripts

Posted: Sat Apr 24, 2010 12:20 pm
by .faust
Spadge, Thanks.