Skip to content

Instantly share code, notes, and snippets.

@ffomenko
Created August 13, 2010 10:37
Show Gist options
  • Save ffomenko/522673 to your computer and use it in GitHub Desktop.
Save ffomenko/522673 to your computer and use it in GitHub Desktop.
#!/sbin/runscript
# Copyright 2008 Dirkjan Ochtman
# Distributed under the terms of the GNU General Public License v2
BACKGROUND=true
HOME="/var/lib/couchdb"
EXEC="/usr/bin/couchdb"
COUCHDB_USER="couchdb"
COUCHDB_PID_FILE="/var/run/couchdb/couchdb.pid"
COUCHDB_STDOUT_FILE="/dev/null"
COUCHDB_STDERR_FILE="/dev/null"
#COUCHDB_RESPAWN_TIMEOUT=
#COUCHDB_OPTIONS=
depend() {
need net
}
start() {
ebegin "Starting ${SVCNAME}"
args="-b"
if test -n "$COUCHDB_STDOUT_FILE"; then
args="$args -o $COUCHDB_STDOUT_FILE"
fi
if test -n "$COUCHDB_STDERR_FILE"; then
args="$args -e $COUCHDB_STDERR_FILE"
fi
if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then
args="$args -r $COUCHDB_RESPAWN_TIMEOUT"
fi
if test -n "$COUCHDB_OPTIONS"; then
args="$args $COUCHDB_OPTIONS"
fi
if test -n "$COUCHDB_PID_FILE"; then
args="$args -p $COUCHDB_PID_FILE"
else
echo "* ERROR: COUCHDB_PID_FILE must be set"
return -1
fi
if test -z "$COUCHDB_USER"; then
echo "* ERROR: COUCHDB_USER must be set"
return -1
fi
start-stop-daemon --start --exec ${EXEC} --name beam \
--user ${COUCHDB_USER} --chuid ${COUCHDB_USER} --pidfile ${COUCHDB_PID_FILE} -- $args
eend $? "Failed to start ${SVCNAME}"
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --exec ${EXEC} --name beam \
--pidfile ${COUCHDB_PID_FILE}
eend $? "Failed to stop ${SVCNAME}"
}
include_recipe "erlang"
package "dev-db/couchdb" do
action :install
end
directory "/var/lib/couchdb" do
owner "couchdb"
group "couchdb"
recursive true
end
remote_file "/etc/init.d/couchdb" do
source "couchdb.init"
owner "root"
group "root"
mode "0755"
end
execute "start-couchdb" do
user "root"
command %Q{
/etc/init.d/couchdb start
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment