All pastes #641071 Raw Edit

ks

public shellscript v1 · immutable
#641071 ·published 2007-07-31 22:18 UTC
rendered paste body
#!/bin/bash# chkconfig: 2345 55 25# description: Elastic Drive startup script# Modified on 7/31/2007# this is variables declarationBASEDIR=`dirname $0`PID=`cat "$BASEDIR/elasticdrive.pid"`# this is control codeif [[ "$1" == "help" ]]; then       help_edfiif [[ "$1" == "restart" ]] && [[ -e "$BASEDIR/elasticdrive.pid" ]]; then        restart_ed        exit $?elif [[  "$1" == "restart" ]];then        echo "Cannot stop elasticdrive. Not running."        exit 1fiif [[ -e $BASEDIR/elasticdrive.pid ]] && [[ -e "$BASEDIR/elasticdrive.pid" ]]; then        if [[ "$1" == "stop" ]];then               stop_ed        else                echo "Elastic drive is already running with PID:`cat $BASEDIR/elasticdrive.pid`"                echo "If this is a stale PID, just delete the file."                exit 1        fifi# this is library of functionsfunction start_ed  {        if check_ids ; then                "$BASEDIR/elasticdrive" start                python "$BASEDIR/s3_nbd_server.pyc" 2>>$BASEDIR/logs/elasticdrive.log 1>>$BASEDIR/logs/elasticdrive.log & PID$                echo $PID > "$BASEDIR/elasticdrive.pid"                echo "Started elasticdrive as pid $PID"                exit 0        else        echo "Please enter your access id information in config.ini \n see AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY";        exit 1fi}function stop_ed  {         echo "Killing $PID"         kill $PID         rm "$BASEDIR/elasticdrive.pid"         exit 0}function restart_ed  {        stop_ed        start_ed        exit 0}function help_ed {        echo "Usage: elasticdrive [start|stop|restart]"        exit 1}function check_ids {        # get file handle        if  [[ -e "$BASEDIR/config.ini" ]]; then                echo "File config.ini is not found in $BASEDIR ! Exiting setup..."                exit 0        else        # check whether ids are present                if grep 'XXXX' $BASEDIR/config.ini; then                        exit 0                else                        exit 1                fifi}start_ed