Skip to content

Instantly share code, notes, and snippets.

@zyegfryed
Created November 28, 2013 14:56
Show Gist options
  • Save zyegfryed/7693173 to your computer and use it in GitHub Desktop.
Save zyegfryed/7693173 to your computer and use it in GitHub Desktop.
Couchbase Query Engine (tuqtng) init script
#!/bin/bash
#
# /etc/rc.d/init.d/tuqtng
#
# Start up the Couchbase Query Language service daemon
#
# chkconfig: 2345 20 80
#
# processname: tuqtng
# config: /etc/sysconfig/tuqtng
### BEGIN INIT INFO
# Provides: tuqtng
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start up the Couchbase Query Language service daemon
### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NAME="tuqtng"
LOCK_FILE=/var/lock/subsys/$NAME
RETVAL=0
# default settings
PROG=/usr/local/bin/cbq-engine
LOG_FILE=/var/log/tuqtng.log
ARGS="-couchbase http://127.0.0.1:8091 >> $LOG_FILE 2>&1"
# pull in sysconfig settings
if [ -f /etc/sysconfig/tuqtng ]; then
. /etc/sysconfig/tuqtng
fi
start() {
[ -x $PROG ] || exit 5
[ $UID -ne 0 ] && exit 4
echo -n "Starting ${NAME}: "
daemon $PROG $ARGS &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCK_FILE && success || failure
echo
return $RETVAL
}
stop() {
[ $UID -ne 0 ] && exit 4
echo -n "Shutting down ${NAME}: "
killproc $PROG && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
echo
return $RETVAL
}
restart() {
stop
start
}
rh_status() {
status $NAME
RETVAL=$?
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rh_status
;;
restart)
restart
;;
*)
echo "Usage: ${SCRIPTNAME} {start|stop|status|restart}"
RETVAL=2
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment