#!/bin/sh
# $Id$
#
# Script: Configure/Deconfigure CTLD
#
# Description: Script to modify /var/etc/ctl.conf and reload ctld service.
#
# Platform: Awanstor
#
# Author: High-Availability.Com Ltd/Awanstor

. /opt/HAC/bin/rsf.sh
#. /etc/rc.d/ctld 

set -x

service=${RSF_SERVICE:-"service_name"}
script="`basename $0`"
state=$1
attempt=${2:-'1'}

case "${state}" in

    'start') # this section tells RSF-1 what to do on service start
        dated_echo "modifying /var/etc/ctl.conf and reloading ctld" # This prints in rsfmon.log when the script is ran
        #
        ########################
        #                      #
        # README README README #
        #                      #
        ########################
        # AT THIS POINT /var/etc/ctl.conf needs updating with
        # any iSCSI shares/portal groups etc required
        # for this pool. The pool name is held in ${service}
        #
        # EXAMPLE cat /root/ctl-poolA.conf >> /var/etc/ctl.conf # this line modifies ctl.conf file on service start
        # NOTE in our implamentation we have a ctl.conf in
        # the pool which we can then add to /var/etc/ctl.conf
        service ctld reload # this reloads the ctld service
        rc_exit ${service} ${RSF_OK}
        ;;

    'stop') # this section tells RSF-1 what to do on service stop
        dated_echo "modifying /var/etc/ctl.conf and fake reloading ctld" # Printing a message into rsfmon.log again
        ########################
        #                      #
        # README README README #
        #                      #
        ########################
        # AT THIS POINT any configuration for the pool
        # needs to be REMOVED from /etc/ctl.conf - again
        # we did this by using include files and removing
        # a single entry - BUT as you have your own
        # requirments you will need to remove the pool
        # specific elements from /etc/ctl.conf.
        #
        service ctld fakereload # Fake Reload the ctld service
        rc_exit ${service} ${RSF_OK}
        ;;

    'check')
        exit ${RSF_CHECK_NORESRC}
        ;;
    *)
        rc_exit ${service} ${RSF_WARN} "usage: $0 <start|stop|check>"
        ;;
esac

