Created
May 19, 2009 14:59
-
-
Save e1senh0rn/114158 to your computer and use it in GitHub Desktop.
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 | |
#ROLE: server, upstream | |
ROLE="upstream" | |
CONFIG=/usr/local/etc/scribe/$ROLE.conf | |
. /etc/rc.subr | |
name="scribed" | |
rcvar=`set_rcvar` | |
command="/usr/local/bin/${name}" | |
command_args="-c $CONFIG" | |
pidfile="/var/run/${name}.pid" | |
start_precmd=start_precmd | |
start_cmd=start_cmd | |
stop_postcmd=stop_postcmd | |
[ -z "$scribed_enable" ] && scribed_enable="YES" | |
start_precmd() { | |
for DBDIR in $(cat $CONFIG | grep 'file_path' | cut -d '=' -f 2); do | |
[ -d $DBDIR ] || mkdir -p $DBDIR | |
done | |
} | |
start_cmd() { | |
# We need to double background to detach from console | |
($command $command_args > /dev/null 2>/dev/null &) & | |
} | |
start_postcmd() { | |
PID=`ps axu | /usr/bin/grep scribed | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}'` | |
[ -z $PID ] && exit 1 | |
echo $PID > $pidfile | |
} | |
stop_postcmd() { | |
rm -f $pidfile | |
} | |
#load_rc_config $name | |
run_rc_command "$1" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment