Sophie

Sophie

distrib > Mandriva > 2011.0 > x86_64 > by-pkgid > 643e52b8152f27afd429cd78d057ca1d > files > 5

kerrighed-2.4.3-1mdv2010.1.src.rpm

#! /bin/sh
#
# kerrighed     start or stop kerrighed cluster
#
# Author:	Jean Parpaillon <jean.parpaillon@irisa.fr>
#               PARIS Research Team - IRISA
#
# Copyright:    INRIA-IRISA - 2006-2007
#

set -e

# chkconfig: 2345 15 02
# description: Insert the node into a kerrighed cluster

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

NAME=kerrighed
DESC="Kerrighed"

KRG_MODULE=$NAME

CFG=/etc/default/$NAME
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
modinfo $KRG_MODULE &>/dev/null || exit 0

# Read config file if it is present.
if [ -r $CFG ]; then
    . $CFG
fi

. /lib/lsb/init-functions

#
# Function that check if Kerrighed can be started
#
d_check_for_no_start() {
    case "x$ENABLE" in
	xtrue)
	    ;;
	xfalse)
	    log_end_msg 0
	    log_warning_msg "Kerrighed disabled in $CFG; not starting Kerrighed"
	    exit 0
	    ;;
	*)  
	    log_end_msg 1
	    log_failure_msg "Value of ENABLE in $CFG must be either 'true' or 'false';"
	    exit 1
	    ;;
    esac
}

#
# Function that starts the daemon/service.
#
d_start() {
    /sbin/modprobe -q $KRG_MODULE $ARGS
}

#
# Function that stops the daemon/service.
#
d_stop() {
    true
}

#
# Function that prints if kerrighed is started or not
#
d_status() {
    PAT='^$KRG_MODULE'
    LOADED=`/sbin/lsmod | egrep $PAT`
    if test -z "$LOADED"; then
	echo -n "not started"
    else
	echo -n "started"
    fi
}

case "$1" in
    start)
	log_begin_msg "Starting $DESC: "
	d_check_for_no_start
	d_start || log_end_msg 1
	log_end_msg 0
	;;
    stop)
	log_begin_msg "Stopping $DESC: "
	d_stop || log_end_msg 1
	log_end_msg 0
	;;
    status)
	log_begin_msg "$DESC status: "
	d_status
	log_end_msg 0
	;;
    restart)
	log_begin_msg "Restart $DESC: "
	d_stop || log_end_msg 1
	d_check_for_no_start
	d_start || log_end_msg 1
	log_end_msg 0
	;;	
    *)
	log_succes_msg "Usage: $SCRIPTNAME {start|stop|restart|status}"
	exit 1
	;;
esac

exit 0