Attached is a re-tooled version of the rc.d script that moves things around into a more standardized format. The big changes are adding KEYWORD: shutdown (which should be done for scripts that start persistent services), and not unconditionally running the code to tweak the flags.

Enjoy,

Doug

--

        Improve the effectiveness of your Internet presence with
        a domain name makeover!    http://SupersetSolutions.com/

        Computers are useless. They can only give you answers.
                        -- Pablo Picasso

#!/bin/sh

# $FreeBSD$
#
# PROVIDE: couchdb
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# couchdb_enable (bool):        Set to NO by default.
#                               Set it to YES to enable couchdb.
#
# couchdb_enablelogs (bool):    Set to YES by default.
#
# couchdb_etcdir (string):      In case you want another dir
#                               for default.ini/local.ini.
#
# couchdb_respawn (int):        Set to none by default. If CouchDB crashes,
#                               respawn after this many seconds.

. /etc/rc.subr

name="couchdb"
rcvar=${name}_enable

command="%%PREFIX%%/bin/${name}"
pidfile="/var/run/${name}/${name}.pid"
etcdir="%%PREFIX%%/etc/${name}"

start_precmd=${name}_prestart
stop_cmd="${command} -d && rm -f ${pidfile}"
status_cmd="${command} -s"

couchdb_prestart()
{
        if [ "$couchdb_respawn" -gt 0 ]; then
                respawn="-r ${couchdb_respawn} "
        fi

        if [ "$couchdb_enablelogs" = "YES" ]; then
                logfile=/var/log/${name}/couch.log
                errfile=/var/log/${name}/err.log
        else
                logfile=/dev/null
                errfile=/dev/null
        fi

        touch $pidfile
        chown $couchdb_user $pidfile
}

load_rc_config $name

: ${couchdb_enable="NO"}
: ${couchdb_respawn:-"0"}"
: ${couchdb_user:-"couchdb"}"
: ${couchdb_enablelogs:-"YES"}"
: ${couchdb_etcdir:-"%%PREFIX%%/etc/couchdb"}"
: ${couchdb_flags="-b -a ${etcdir}/default.ini -a ${etcdir}/local.ini 
${respawn}-o ${logfile} -e ${errfile} -p ${pidfile}"}

run_rc_command "$1"
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to