Skip to content

Instantly share code, notes, and snippets.

@daimor
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daimor/10009450 to your computer and use it in GitHub Desktop.
Save daimor/10009450 to your computer and use it in GitHub Desktop.
GlobalsDB starts script
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: GlobalsDB
# Required-Start:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts GlobalsDB
# Description: Starts GlobalsDB
### END INIT INFO
. /etc/rc.d/init.d/functions
[ -f /etc/sysconfig/globalsdb ] && . /etc/sysconfig/globalsdb
if [ "$GLOBALS_HOME" ]; then
if [ ! -d "$GLOBALS_HOME/mgr" ]; then
echo "$GLOBLAS_HOME/mgr directory not found!" >&2 ; exit 1
fi
cd $GLOBALS_HOME/mgr
else
echo "GLOBALS_HOME is empty" >&2 ; exit 1
fi
mgrdir=`pwd`
start() {
echo -n "Starting Globals in $mgrdir:"
args=""
test "$MEMORY" && args=$args' memory='$MEMORY
./startGlobals quietly $args 1>/dev/null 2>/dev/null
status=$?
if [ $status -eq 0 ] ; then
success
else
failure
fi
echo
return $status
}
stop() {
echo -n "Stopping Globals in $mgrdir: "
./stopGlobals 1>/dev/null 2>/dev/null
status=$?
if [ $status -eq 0 ] ; then
success
else
failure
fi
echo
return $status
}
restart() {
stop
status=$?
if [ $status -ne 0 ] ; then
return $status
fi
start
status=$?
if [ $status -ne 0 ] ; then
return $status
fi
return ${status}
}
status() {
../bin/cache -s . -cV 1>/dev/null 2>/dev/null
status=$?
case $status in
225) echo "Globals in $mgrdir is stopped"
exit 1
;;
*)
echo "Globals in $mgrdir is running"
exit 1
;;
esac
return 0
}
usage() {
echo "Usage: `basename $0` {start|stop|restart|status|help}"
return 0
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
case "$1" in
start)
start
exit $?
;;
stop)
stop
exit $?
;;
restart)
restart
exit $?
;;
status)
status
exit $?
;;
help)
usage
exit $?
;;
*)
usage
exit 1
;;
esac
# Example of /etc/sysconfig/globalsdb
# Globals home directory
GLOBALS_HOME=/opt/globalsdb
# Configure MB of database buffers (default=256)
MEMORY=1024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment