Skip to content

Instantly share code, notes, and snippets.

@mike-zhang
Forked from sbisbee/gist:1320996
Created August 20, 2014 06:06
Show Gist options
  • Save mike-zhang/1a35b380bac510ad8795 to your computer and use it in GitHub Desktop.
Save mike-zhang/1a35b380bac510ad8795 to your computer and use it in GitHub Desktop.

Revisions

  1. @sbisbee sbisbee revised this gist Oct 28, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash
    #
    # chkconfig: 23 90 10
    # Description: Quickly hacked together bigcouch init script for CentOS systems.

    . /etc/init.d/functions

  2. @sbisbee sbisbee revised this gist Oct 27, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ PID_FILE=/var/run/bigcouch.pid
    BIGCOUCH_BIN=/opt/bigcouch/bin/bigcouch
    SUBSYS_LOCK_FILE=/var/lock/subsys/bigcouch

    export HOME=/tmp

    start() {
    echo -n "Starting bigcouch: "

  3. @sbisbee sbisbee revised this gist Oct 27, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    #!/bin/bash
    #
    # chkconfig: 23 90 10

    . /etc/init.d/functions

  4. @sbisbee sbisbee created this gist Oct 27, 2011.
    72 changes: 72 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    #!/bin/bash

    . /etc/init.d/functions

    PID_FILE=/var/run/bigcouch.pid
    BIGCOUCH_BIN=/opt/bigcouch/bin/bigcouch
    SUBSYS_LOCK_FILE=/var/lock/subsys/bigcouch

    start() {
    echo -n "Starting bigcouch: "

    if [ -f "$PID_FILE" ]; then
    echo "already running: "`cat $PID_FILE`
    exit 2
    fi

    $BIGCOUCH_BIN &>/dev/null &
    echo $! > $PID_FILE

    touch $SUBSYS_LOCK_FILE

    echo "OK"
    }

    stop() {
    echo -n "Shutting down bigcouch: "

    if [ ! -f "$PID_FILE" ]; then
    echo "already stopped"
    else
    kill -9 `cat $PID_FILE`

    rm -f $PID_FILE
    rm -f $SUBSYS_LOCK_FILE

    echo "OK"
    fi
    }

    status() {
    if [ -f "$PID_FILE" ]; then
    echo "Running with PID "`cat $PID_FILE`
    else
    echo "Not running"
    fi
    }

    case "$1" in
    start)
    start
    ;;

    stop)
    stop
    ;;

    restart)
    stop
    start
    ;;

    status)
    status
    ;;

    *)
    echo "Usage: [start|stop|restart|status]"
    exit 1
    ;;
    esac

    exit $?