[MonetDB-users] Shell script to start MonetDB as service on Linux

McKennirey.Matthew mmckennirey at dpfuture.biz
Thu Dec 13 20:48:15 CET 2007


Fabian, thanks for your quick reply, and pointing me in the right direction. 
We are running on OpenSuse, and for the moment have settled on the following 
script. I'm sure it could use a lot of improvement, but we are up and running 
**********

!/bin/sh

# Portions Copyright (c) 1995-2002 SuSE Linux AG Nuernberg, Germany.
# Author: Lenz Grimmer <feedback at suse.de>
#
# /etc/init.d/monetdb

### BEGIN INIT INFO
# Provides:       monetdb
# Required-Start: $network $remote_fs
# Required-Stop:
# Default-Start:  2 3 5
# Default-Stop:
# Description:    Start the MonetDB database server
### END INIT INFO

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
 /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 

# update these as appropriate for your server
MDB_USER='root'
MDB_GROUP='root'
MDB_HOME=/srv/monetdb
MDB_BINDIR=/srv/monetdb/bin

echo ""
echo "Using configuration at " $MDB_HOME/etc/monetdb5.conf
echo ""

# Test, if path to merovingian is valid
unset MEROVINGIAN
if test -x $MDB_BINDIR/merovingian
then
        MEROVINGIAN=$MDB_BINDIR/merovingian
fi
test "$MEROVINGIAN" || { echo "MonetDB daemon (merovingian) is not available 
at indicated path:" $MDB_BINDIR  "verify path settings in /etc/monetdb"; 
rc_failed 5; rc_status -v; rc_exit; }


depend() {
	use net
}

start(){
	echo -n "Starting MonetDB/SQL"
	startproc -s -u $MDB_USER -g $MDB_GROUP $MDB_BINDIR/merovingian

	# Rmember status and be verbose
	rc_status -v
}

stop() {
	echo -n "Stopping MonetDB/SQL"
	
	# shut down mserver if it is running
	kill -INT $(pidof mserver5)

	# stop merovingian daemon
	kill -INT $(pidof merovingian)

	# Remember status and be verbose
	rc_status -v
}

status(){
	echo -n "Checking for MonetDb service: "

	# NOTE: checkproc returns LSB compliant status values.
	checkproc $MEROVINGIAN
	rc_status -v
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage:  {start|stop|status|restart}"
        exit 1
        ;;
esac
rc_exit




More information about the users-list mailing list