diff options
| author | Micah <micah@leap.se> | 2016-07-12 16:45:54 -0400 | 
|---|---|---|
| committer | Micah <micah@leap.se> | 2016-07-12 16:45:54 -0400 | 
| commit | f2019755fd724fb1020cb2d97cdf82b751450ebc (patch) | |
| tree | 1c2bd3a4f03b84795ea0ce0b7ccc0f28a2ecbadd /puppet/modules/couchdb/files/Debian | |
| parent | 81210aea5cf136194598e7a399ce307ecbe088f1 (diff) | |
git subrepo clone https://leap.se/git/puppet_couchdb puppet/modules/couchdb
subrepo:
  subdir:   "puppet/modules/couchdb"
  merged:   "76ff149"
upstream:
  origin:   "https://leap.se/git/puppet_couchdb"
  branch:   "master"
  commit:   "76ff149"
git-subrepo:
  version:  "0.3.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "1e79595"
Change-Id: I9ccb1a9dfdaa083814ea395132c42a778052f59b
Diffstat (limited to 'puppet/modules/couchdb/files/Debian')
| -rwxr-xr-x | puppet/modules/couchdb/files/Debian/couchdb | 160 | 
1 files changed, 160 insertions, 0 deletions
| diff --git a/puppet/modules/couchdb/files/Debian/couchdb b/puppet/modules/couchdb/files/Debian/couchdb new file mode 100755 index 00000000..ccdfe716 --- /dev/null +++ b/puppet/modules/couchdb/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 $@ | 
