From 7e899eaeace19e1248db6ff2a1e70bb39af5848b Mon Sep 17 00:00:00 2001 From: varac Date: Sat, 9 Mar 2013 21:16:49 +0100 Subject: couchdb init file moved from site_couchdb to couchdb module --- files/Debian/couchdb | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100755 files/Debian/couchdb (limited to 'files') diff --git a/files/Debian/couchdb b/files/Debian/couchdb new file mode 100755 index 0000000..ccdfe71 --- /dev/null +++ b/files/Debian/couchdb @@ -0,0 +1,160 @@ +#!/bin/sh -e + +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +### BEGIN INIT INFO +# Provides: couchdb +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Apache CouchDB init script +# Description: Apache CouchDB init script for the database server. +### END INIT INFO + +SCRIPT_OK=0 +SCRIPT_ERROR=1 + +DESCRIPTION="database server" +NAME=couchdb +SCRIPT_NAME=`basename $0` +COUCHDB=/usr/bin/couchdb +CONFIGURATION_FILE=/etc/default/couchdb +RUN_DIR=/var/run/couchdb +LSB_LIBRARY=/lib/lsb/init-functions + +if test ! -x $COUCHDB; then + exit $SCRIPT_ERROR +fi + +if test -r $CONFIGURATION_FILE; then + . $CONFIGURATION_FILE +fi + +log_daemon_msg () { + # Dummy function to be replaced by LSB library. + + echo $@ +} + +log_end_msg () { + # Dummy function to be replaced by LSB library. + + if test "$1" != "0"; then + echo "Error with $DESCRIPTION: $NAME" + fi + return $1 +} + +if test -r $LSB_LIBRARY; then + . $LSB_LIBRARY +fi + +run_command () { + command="$1" + if test -n "$COUCHDB_OPTIONS"; then + command="$command $COUCHDB_OPTIONS" + fi + if test -n "$COUCHDB_USER"; then + if su $COUCHDB_USER -c "$command"; then + return $SCRIPT_OK + else + return $SCRIPT_ERROR + fi + else + if $command; then + return $SCRIPT_OK + else + return $SCRIPT_ERROR + fi + fi +} + +start_couchdb () { + # Start Apache CouchDB as a background process. + + mkdir -p "$RUN_DIR" + chown -R "$COUCHDB_USER" "$RUN_DIR" + command="$COUCHDB -b" + if test -n "$COUCHDB_STDOUT_FILE"; then + command="$command -o $COUCHDB_STDOUT_FILE" + fi + if test -n "$COUCHDB_STDERR_FILE"; then + command="$command -e $COUCHDB_STDERR_FILE" + fi + if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then + command="$command -r $COUCHDB_RESPAWN_TIMEOUT" + fi + run_command "$command" > /dev/null +} + +stop_couchdb () { + # Stop the running Apache CouchDB process. + + run_command "$COUCHDB -d" > /dev/null + pkill -u couchdb + # always return true even if no remaining couchdb procs got killed + /bin/true +} + +display_status () { + # Display the status of the running Apache CouchDB process. + + run_command "$COUCHDB -s" +} + +parse_script_option_list () { + # Parse arguments passed to the script and take appropriate action. + + case "$1" in + start) + log_daemon_msg "Starting $DESCRIPTION" $NAME + if start_couchdb; then + log_end_msg $SCRIPT_OK + else + log_end_msg $SCRIPT_ERROR + fi + ;; + stop) + log_daemon_msg "Stopping $DESCRIPTION" $NAME + if stop_couchdb; then + log_end_msg $SCRIPT_OK + else + log_end_msg $SCRIPT_ERROR + fi + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESCRIPTION" $NAME + if stop_couchdb; then + if start_couchdb; then + log_end_msg $SCRIPT_OK + else + log_end_msg $SCRIPT_ERROR + fi + else + log_end_msg $SCRIPT_ERROR + fi + ;; + status) + display_status + ;; + *) + cat << EOF >&2 +Usage: $SCRIPT_NAME {start|stop|restart|force-reload|status} +EOF + exit $SCRIPT_ERROR + ;; + esac +} + +parse_script_option_list $@ -- cgit v1.2.3 From d08b3bdcb54e8991fe418ed6401ceffb77441b34 Mon Sep 17 00:00:00 2001 From: varac Date: Sun, 10 Mar 2013 16:18:09 +0100 Subject: added port parameter to couch-doc-update (for bigcouch support) --- files/couch-doc-update | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'files') diff --git a/files/couch-doc-update b/files/couch-doc-update index 9ba6db7..45d9f87 100644 --- a/files/couch-doc-update +++ b/files/couch-doc-update @@ -14,7 +14,7 @@ # # USAGE # -# couch-doc-update --db --id --data +# couch-doc-update --port --db --id --data # # EXAMPLE # @@ -24,6 +24,8 @@ # update a user: # couch-doc-update --db _users --id org.couchdb.user:ca_daemon --data '{"password":"sssshhh"}' # +# To update the _users DB on bigcouch, you must connect to port 5986 instead of the default couchdb port 5984 +# begin; require 'rubygems'; rescue LoadError; end # optionally load rubygems require 'couchrest' @@ -33,11 +35,13 @@ def main # # parse options # + @port = "5984" @db_name = nil @doc_id = nil @new_data = nil loop do case ARGV[0] + when '--port' then ARGV.shift; @port = ARGV.shift when '--db' then ARGV.shift; @db_name = ARGV.shift when '--id' then ARGV.shift; @doc_id = ARGV.shift when '--data' then ARGV.shift; @new_data = ARGV.shift @@ -47,12 +51,12 @@ def main end usage("Missing required option") unless @db_name && @doc_id && @new_data @new_data = JSON.parse(@new_data) - + # # update document # begin - @db = CouchRest.database(connection_string(@db_name)) + @db = CouchRest.database(connection_string(@db_name, @port)) @doc = get_document(@db, @doc_id) result = if @doc update_document(@db, @doc, @new_data) @@ -87,10 +91,10 @@ def create_document(db, doc_id, data) db.save_doc(data) end -def connection_string(database) +def connection_string(database, port) protocol = "http" hostname = "127.0.0.1" - port = "5984" + #port = "5984" username = "admin" password = "" @@ -109,7 +113,7 @@ end def usage(s) $stderr.puts(s) - $stderr.puts("Usage: #{File.basename($0)} --db --id --data ") + $stderr.puts("Usage: #{File.basename($0)} --port --db --id --data ") exit(2) end -- cgit v1.2.3