Skip to content

Instantly share code, notes, and snippets.

@e1senh0rn
Created May 19, 2009 14:59
Show Gist options
  • Save e1senh0rn/114158 to your computer and use it in GitHub Desktop.
Save e1senh0rn/114158 to your computer and use it in GitHub Desktop.
#!/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