ports/databases/couchdb/files/couchdb.in
Chris Rees bf5bbb00fa - Update to 1.2.0
- OPTIONSngify

- Error out on build if older version installed with config file present; this
  must be backed up or it will be lost on deinstall.

- Shift default DB storage location from /var/lib/couchdb to
  /var/db/couchdb to make it consistent with other DB storage engine ports
  which use /var/db as their base (eg; mySQL).

PR:		ports/168923
Submitted by:	Adam Strohl <adams-ports@ateamsystems.com>
Approved by:	maintainer timeout (till@php.net, >14 days)
2012-07-02 21:31:27 +00:00

73 lines
1.7 KiB
Bash

#!/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=couchdb_enable
load_rc_config $name
: ${couchdb_enable="NO"}
couchdb_user="${couchdb_user:-"couchdb"}"
couchdb_enablelogs="${couchdb_enablelogs:-"YES"}"
couchdb_etcdir="${couchdb_etcdir:-"%%PREFIX%%/etc/couchdb"}"
couchdb_respawn="${couchdb_respawn:-"0"}"
command="%%PREFIX%%/bin/${name}"
pidfile="/var/run/${name}/${name}.pid"
urifile="/var/run/${name}/couch.uri"
command_args="-p ${pidfile} -b"
couchdb_prestart()
{
install -o $couchdb_user /dev/null $pidfile
install -o $couchdb_user /dev/null $urifile
if [ -n "$couchdb_flags" ]; then
case "$couchdb_flags" in
*-[bp]*) err 1 'The -b and -p options should be removed from couchdb_flags' ;;
esac
return 0
fi
if [ $couchdb_respawn -gt 0 ]; then
respawn="-r ${couchdb_respawn}"
fi
if checkyesno couchdb_enablelogs; then
logfile=/var/log/${name}/couch.log
errfile=/var/log/${name}/err.log
else
logfile=/dev/null
errfile=/dev/null
fi
command_args="-a ${couchdb_etcdir}/default.ini -a ${couchdb_etcdir}/local.ini ${respawn} -o ${logfile} -e ${errfile} ${command_args}"
}
start_precmd=${name}_prestart
stop_cmd="${command} -d"
status_cmd="${command} -s"
run_rc_command "$1"