#!/bin/sh
###############################################################################
#
#          Dell Inc. PROPRIETARY INFORMATION
# This software is supplied under the terms of a license agreement or
# nondisclosure agreement with Dell Inc. and may not
# be copied or disclosed except in accordance with the terms of that
# agreement.
#
# Copyright (c) 2013 Dell Inc. All Rights Reserved.
#
# Module Name:
#
#   dcismeng
#
# Abstract/Purpose:
#
#   iDRAC Service Module startup script
#
# Environment:
#
#   Linux
#
# Following two lines used by chkconfig utility:
# chkconfig: 35 96 04
# description: iDRAC Service Module startup script
#
### BEGIN INIT INFO
# Provides: dcismeng
# Should-Start: ipmi
# Required-Start: $localfs $remotefs $syslog
# Required-Stop: $localfs $remotefs $syslog
# Default-Start: 3 5
# Default-Stop: 1 2
# Short-Description: iDRAC Service Module startup script
# Description: iDRAC Service Module startup script
### END INIT INFO
#
###############################################################################

ISM_PROD_NAME="iDRAC Service Module"
ISM_SCRIPT_NAME="dcismeng"
ISM_DEFAULT_INSTALL_DIR="/opt/dell/srvadmin/iSM"

# Make sure HOSTTYPE is set
[ -z "${HOSTTYPE}" ] && HOSTTYPE=$(uname -m)

# OS information
OM_INITSCRIPT_DIR="/opt/dell/srvadmin/iSM/etc/init.d"
OS_INITSCRIPT_DIR="/etc/init.d"
OS_SUBSYS_LOCK_DIR="/opt/dell/srvadmin/iSM/var/lock/subsys/"
OS_SCRIPT_FUNCTIONS_LSB="/lib/lsb/init-functions"
OS_SCRIPT_FUNCTIONS_RH="/etc/init.d/functions"
OS_SCRIPT_FUNCTIONS_NONE="none"
# OpenIPMI-specific variables
OPENIPMI_SCRIPT="${OS_INITSCRIPT_DIR}/ipmi"

# Check for supported OS script functions
if [ -f ${OS_SCRIPT_FUNCTIONS_RH} ];
then
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_RH}
elif [ -f ${OS_SCRIPT_FUNCTIONS_LSB} ];
then
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_LSB}
else
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_NONE}
fi

# Include OS script functions if available
if [ ${OS_SCRIPT_FUNCTIONS} != ${OS_SCRIPT_FUNCTIONS_NONE} ];
then
	. ${OS_SCRIPT_FUNCTIONS}
fi

if [ "$(uname -s)" = "VMkernel" ];
then
	OS_KERNEL_VMKERNEL=1
else
	OS_KERNEL_VMKERNEL=0
fi

ISM_INSTALLPATH_KEY="ISM.installpath"

ISM_DAEMON_DIR="/opt/dell/srvadmin/iSM/sbin"
ISM_LOCK_FILE="${OS_SUBSYS_LOCK_DIR}/${ISM_SCRIPT_NAME}"
ISM_LD_LIBRARY_PATH_SET=0

OMIL_SYSCHECK_SCRIPT="/opt/dell/srvadmin/iSM/sbin/CheckSystemType"
OMIL_SYSCHECK_SCRIPT_LOADED=0



# Standard status codes for commands other than "status"
STATUS_NO_ERROR=0
STATUS_GENERIC_ERROR=1
STATUS_INVALID_ARG=2
STATUS_NOT_IMPLEMENTED=3

# iSM Engine status codes for commands other than "status"
STATUS_SYSTEM_NOT_SUPPORTED=252

# Standard status codes for "status" command
STATUS_RUNNING=0
STATUS_DEAD_PIDFILE_EXISTS=1
STATUS_DEAD_LOCKFILE_EXISTS=2
STATUS_NOT_RUNNING=3
STATUS_UNKNOWN=4
STATUS_NOT_STARTED=5

# Default to no daemons enabled
ISM_DAEMON_ALL_LIST=""
ISM_DAEMON_START_LIST=""
ISM_DAEMON_STOP_LIST=""
ISM_DAEMONS_ENABLED=0
ISM_DCSNMP_INSTALLED=0
ISM_DCSNMP_ENABLED=0

# Check for ISM Manager
	ISM_DCSTOR="dsm_ism_srvmgrd"
		ISM_DAEMON_ALL_LIST="${ISM_DAEMON_ALL_LIST} ${ISM_DCSTOR}"
		ISM_DAEMON_START_LIST="${ISM_DAEMON_START_LIST} ${ISM_DCSTOR}"
		ISM_DAEMON_STOP_LIST="${ISM_DCSTOR} ${ISM_DAEMON_STOP_LIST}"
		ISM_DAEMONS_ENABLED=1

###############################################################################
# Begin Functions
###############################################################################


###############################################################################
# Function:    dcismeng_start
# Description: Start iSM Engine daemons
# Returns:     LSB status codes
###############################################################################
dcismeng_start()
{
	local msg status

	# Check if system supported
	dcismeng_check_system_type
	status=$?
	if [ ${status} != ${STATUS_NO_ERROR} ];
	then
		echo "Starting ${ISM_PROD_NAME}:"
		msg="Failed to start because system is not supported"
		echo "${msg}"
		dcismeng_supt_logmessage "${ISM_PROD_NAME}: ${msg}"
		return ${status}
	fi

	## start IPMI driver
       	${OPENIPMI_SCRIPT} start >/dev/null 2>&1
        status=$?
	if [ ${status} != ${STATUS_NO_ERROR} ];
        then
		#try using the systemd way
		systemctl list-unit-files | grep -i ipmi >/dev/null 2>&1
		status=$?
		if [ ${status} != ${STATUS_NO_ERROR} ];
        	then
        		msg="${OPENIPMI_SCRIPT} start command failed with status ${status}"
			echo "${msg}"
			dcismeng_supt_logmessage "${ISM_PROD_NAME}: ${msg}"
			return ${status}
		fi
		
		systemctl enable ipmi >/dev/null 2>&1
		status=$?
		if [ ${status} != ${STATUS_NO_ERROR} ];
        	then
        		msg="systemctl enable ipmi command failed with status ${status}"
			echo "${msg}"
			dcismeng_supt_logmessage "${ISM_PROD_NAME}: ${msg}"
			return ${status}
		fi
		systemctl start ipmi >/dev/null 2>&1
		status=$?
		if [ ${status} != ${STATUS_NO_ERROR} ];
        	then
        		msg="systemctl start ipmi command failed with status ${status}"
			echo "${msg}"
			dcismeng_supt_logmessage "${ISM_PROD_NAME}: ${msg}"
			return ${status}
		fi
        fi

	# Check if any iSM Engine daemons are enabled
	if [ ${ISM_DAEMONS_ENABLED} = 0 ];
	then
		echo "Starting ${ISM_PROD_NAME}:"
		echo "No daemons enabled"
		return ${STATUS_NO_ERROR}
	fi


	echo "Starting ${ISM_PROD_NAME}:"

	status="${STATUS_NO_ERROR}"
	# Start any iSM daemons that
	# are currently installed and enabled
	for ISM_DAEMON in ${ISM_DAEMON_START_LIST};
	do
		dcismeng_startdaemon ${ISM_DAEMON}
		status=$?
		if [ ${status} != ${STATUS_NO_ERROR} ];
		then
			break
		fi
		
	done


	return ${status}
} # dcismeng_start




###############################################################################
# Function:    ddcismeng_startdaemon <daemon>
# Description: Start specified daemon
# Returns:     LSB status codes
###############################################################################
dcismeng_startdaemon()
{
	local status
	DAEMON="$1"
	start_status="${STATUS_NO_ERROR}"
	# Check for daemon name
	if [ -z ${DAEMON} ];
	then
		echo "${ISM_SCRIPT_NAME}: daemon not specified"
		return ${STATUS_INVALID_ARG}
	fi

	# Check if daemon is Data Engine daemon and installed
	IS_ISM_DAEMON=0
	for ISM_DAEMON in ${ISM_DAEMON_ALL_LIST};
	do
		if [ "${DAEMON}" = "${ISM_DAEMON}" ];
		then
			IS_ISM_DAEMON=1
			break
		fi
	done
	if [ ${IS_ISM_DAEMON} = 0 ];
	then
		echo "${ISM_SCRIPT_NAME}: ${DAEMON} not ${ISM_PROD_NAME} daemon or not installed"
		return ${STATUS_INVALID_ARG}
	fi

	echo -n "Starting ${DAEMON}: "

	ISM_DAEMON_FILE="${ISM_DAEMON_DIR}/${DAEMON}"
	ISM_DAEMON_OPTS=""

	# Check if system supported
	dcismeng_check_system_type
	status=$?
	if [ ${status} != ${STATUS_NO_ERROR} ];
	then
		echo -n "System not supported"
		dcismeng_supt_showfailure ""
		return ${status}
	fi

	# See if the daemon is running
	dcismeng_supt_daemonstatus ${DAEMON} >/dev/null
	if [ $? != ${STATUS_RUNNING} ];
	then
		# Start the daemon
		dcismeng_supt_daemonstart "${ISM_DAEMON_FILE}" "${ISM_DAEMON_OPTS}"
		start_status=$?
	else
		echo -n "Already started"
		dcismeng_supt_showsuccess ""
	fi

	# Check if any iSM daemons running
	dcismeng_status >/dev/null
	if [ $? = ${STATUS_RUNNING} ];
	then
		# Make sure lock file exists
		# when iSM daemons are running
		[ -d ${OS_SUBSYS_LOCK_DIR} ] && touch ${ISM_LOCK_FILE}
	fi

	return ${start_status}
} # dcismeng_startdaemon


###############################################################################
# Function:    dcismeng_stop
# Description: Stop iSM daemons
# Returns:     LSB status codes
###############################################################################
dcismeng_stop()
{
	status="${STATUS_NO_ERROR}"
	# Check if any iSM daemons are enabled
	if [ ${ISM_DAEMONS_ENABLED} = 0 ];
	then
		echo "Stopping ${ISM_PROD_NAME}:"
		echo "No daemons enabled"
		return ${STATUS_NO_ERROR}
	fi

	echo "Stopping ${ISM_PROD_NAME}:"

	# Stop iSM daemons that are running
	for ISM_DAEMON in ${ISM_DAEMON_STOP_LIST};
	do
		dcismeng_stopdaemon ${ISM_DAEMON}
		status=$?
	done

	return ${status}
} # dcismeng_stop


###############################################################################
# Function:    dcismeng_stopdaemon <daemon>
# Description: Stop specified daemon
# Returns:     LSB status codes
###############################################################################
dcismeng_stopdaemon()
{
	DAEMON="$1"
	stop_status="${STATUS_NO_ERROR}"

	# Check for daemon name
	if [ -z ${DAEMON} ];
	then
		echo "${ISM_SCRIPT_NAME}: daemon not specified"
		return ${STATUS_INVALID_ARG}
	fi

	# Check if daemon is iSM daemon and installed
	IS_ISM_DAEMON=0
	for ISM_DAEMON in ${ISM_DAEMON_ALL_LIST};
	do
		if [ "${DAEMON}" = "${ISM_DAEMON}" ];
		then
			IS_ISM_DAEMON=1
			break
		fi
	done
	if [ ${IS_ISM_DAEMON} = 0 ];
	then
		echo "${ISM_SCRIPT_NAME}: ${DAEMON} not ${ISM_PROD_NAME} daemon or not installed"
		return ${STATUS_INVALID_ARG}
	fi

	echo -n "Stopping ${DAEMON}: "

	# See if the daemon is running
	dcismeng_supt_daemonstatus ${DAEMON} >/dev/null
	if [ $? = ${STATUS_RUNNING} ];
	then
		# Stop the daemon
		dcismeng_supt_daemonstop ${DAEMON}
		stop_status=$?
	else
		echo -n "Not started"
		dcismeng_supt_showfailure ""
		stop_status="${STATUS_NOT_STARTED}"
	fi

	# Check if any iSM daemons still running
	dcismeng_status >/dev/null
	if [ $? = ${STATUS_NOT_RUNNING} ];
	then
		# Make sure lock file removed when
		# no iSM daemons are running
		[ -d ${OS_SUBSYS_LOCK_DIR} ] && rm -f ${ISM_LOCK_FILE}
	fi

	return ${stop_status}
} # dcismeng_stopdaemon


###############################################################################
# Function:    dcismeng_status
# Description: Get status of iSM daemons
# Returns:     LSB status codes
###############################################################################
dcismeng_status()
{
	ISM_STATUS=${STATUS_NOT_RUNNING}

	# Check if any iSM daemons are enabled
	if [ ${ISM_DAEMONS_ENABLED} = 1 ];
	then
		# Get status of iSM daemons
		for ISM_DAEMON in ${ISM_DAEMON_START_LIST};
		do
			dcismeng_supt_daemonstatus ${ISM_DAEMON}
			if [ $? = ${STATUS_RUNNING} ];
			then
				ISM_STATUS=${STATUS_RUNNING}
			fi
		done
	fi

	return ${ISM_STATUS}
} # dcismeng_status


###############################################################################
# Function:    dcismeng_check_system_type
# Description: Check if system supported
# Returns:     LSB status codes
###############################################################################
dcismeng_check_system_type()
{
	if [ -f ${OMIL_SYSCHECK_SCRIPT} ];
	then
		if [ ${OMIL_SYSCHECK_SCRIPT_LOADED} = 0 ];
		then
			. ${OMIL_SYSCHECK_SCRIPT}
			OMIL_SYSCHECK_SCRIPT_LOADED=1
		fi

		IsThisSupportedGeneration
		if [ $? != 0 ];
		then
			return ${STATUS_SYSTEM_NOT_SUPPORTED}
		fi
	fi

	return ${STATUS_NO_ERROR}
} # dcismeng_check_system_type



###############################################################################
# Function:    dcismeng_supt_daemonrunning <daemon> <pid list>
# Description: Check if daemon is running
# Returns:     0 = daemon running, 1 = daemon not running
###############################################################################
dcismeng_supt_daemonrunning()
{
	local daemon pidlist

	daemon=$1

	if [ ${OS_KERNEL_VMKERNEL} = 1 ];
	then
		pidlist=$(pidof -o $$ -o ${PPID} -o %PPID -x ${daemon})
		if [ -n "${pidlist}" ];
		then
			return 0
		fi
	else
		pidlist="$2"
		if [ -n "${pidlist}" ];
		then
			for pid in ${pidlist};
			do
				if [ -d /proc/${pid} ];
				then
					return 0
				fi
			done
		fi
	fi

	return 1
} # dcismeng_supt_daemonrunning


###############################################################################
# Function:    dcismeng_supt_daemonstart <daemon pathfilename> <daemon options>
# Description: Start a daemon
# Returns:     LSB status codes
###############################################################################
dcismeng_supt_daemonstart()
{
	DAEMON_PFNAME="$1"
	DAEMON=`basename ${DAEMON_PFNAME}`
	shift

	# set LD_LIBRARY_PATH if needed
	if [ ${OS_KERNEL_VMKERNEL} = 1 ] && [ -d /lib/cim ];
	then
		if [ ${DENG_LD_LIBRARY_PATH_SET} != 1 ];
		then
			export LD_LIBRARY_PATH=/lib/cim:${LD_LIBRARY_PATH}
			DENG_LD_LIBRARY_PATH_SET=1
		fi
	fi

	if [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_RH} ];
	then
		# Start daemon
		daemon "${DAEMON_PFNAME}" $*
		STATUS=$?
		SHOW_STATUS=0
		echo
	else
		# Start daemon
		"${DAEMON_PFNAME}" $*
		if [ $? = 0 ];
		then
			STATUS=${STATUS_NO_ERROR}
		else
			STATUS=${STATUS_GENERIC_ERROR}
		fi
		SHOW_STATUS=1
	fi

	if [ ${SHOW_STATUS} = 1 ];
	then
		# Display and log status
		if [ ${STATUS} = ${STATUS_NO_ERROR} ];
		then
			dcismeng_supt_showsuccess ""
			dcismeng_supt_logmessage "${DAEMON} startup succeeded"
		else
			dcismeng_supt_showfailure ""
			dcismeng_supt_logmessage "${DAEMON} startup failed"
		fi
	fi

	return ${STATUS}
} # dcismeng_supt_daemonstart


###############################################################################
# Function:    dcismeng_supt_daemonstop <daemon>
# Description: Stop a daemon
# Returns:     LSB status codes
###############################################################################
dcismeng_supt_daemonstop()
{
	DAEMON="$1"
	STATUS=${STATUS_GENERIC_ERROR}

	# Check for daemon name
	if [ -z ${DAEMON} ];
	then
		return ${STATUS}
	fi

	# Get list of pids for daemon
	PIDLIST=""

	# Check for pid file in standard location
	PIDFILE="/opt/dell/srvadmin/iSM/var/run/${DAEMON}.pid"
	if [ -f ${PIDFILE} ];
	then
		# Get list of pids from pid file
		read LINE < ${PIDFILE}
		for PID in ${LINE};
		do
			if [ -d /proc/${PID} ];
			then
				PIDLIST="${PIDLIST} ${PID}"
			fi
		done
	fi

	# Check if list of pids found in pid file
	if [ -z ${PIDLIST} ];
	then
		# Get list of pids using pidof
		PIDLIST=`pidof -o $$ -o ${PPID} -o %PPID -x ${DAEMON}`
	fi

	# Check if list of pids found for daemon
	if [ -n "${PIDLIST}" ];
	then
		# Find pid for main thread; it should be lowest numbered pid
		PIDMAIN=0
		for PID in ${PIDLIST};
		do
			if [ ${PIDMAIN} -eq 0 ] || [ ${PID} -lt ${PIDMAIN} ];
			then
				PIDMAIN=${PID}
			fi
		done

		# Check if pid for main thread found
		if [ ${PIDMAIN} != 0 ];
		then
			# Signal main thread to shutdown
			kill -TERM ${PIDMAIN}
			usleep 100000

			# Wait up to 60 seconds for all daemon threads to go away
			SECS=0
			while [ ${SECS} -lt 60 ];
			do
				if dcismeng_supt_daemonrunning "${DAEMON}" "${PIDLIST}";
				then
					# At least one daemon thread is still running
					sleep 1
					SECS=$((SECS + 1))
				else
					# No daemon threads are running
					break
				fi
			done

			# Check again in case timeout occurred
			if dcismeng_supt_daemonrunning "${DAEMON}" "${PIDLIST}";
			then
				# Refresh list of pids and issue KILL for all remaining threads
				PIDLIST=`pidof -o $$ -o ${PPID} -o %PPID -x ${DAEMON}`
				kill -KILL ${PIDLIST}
				usleep 100000
			fi

			# Check again for return code
			dcismeng_supt_daemonrunning "${DAEMON}" "${PIDLIST}"
			if [ $? != 0 ];
			then
				# No daemon threads are running
				STATUS=${STATUS_NO_ERROR}
			fi
		fi
	fi

	# Display and log status
	if [ ${STATUS} = ${STATUS_NO_ERROR} ];
	then
		dcismeng_supt_showsuccess ""
		dcismeng_supt_logmessage "${DAEMON} shutdown succeeded"
	else
		dcismeng_supt_showfailure ""
		dcismeng_supt_logmessage "${DAEMON} shutdown failed"
	fi

	return ${STATUS}
} # dcismeng_supt_daemonstop


###############################################################################
# Function:    dcismeng_supt_daemonstatus <daemon>
# Description: Get current status of a daemon
# Returns:     LSB status code
###############################################################################
dcismeng_supt_daemonstatus()
{
	DAEMON="$1"

	# Check for daemon name
	if [ -z ${DAEMON} ];
	then
		return ${STATUS_UNKNOWN}
	fi

	# Get list of pids using pidof
	PIDLIST=`pidof -o $$ -o ${PPID} -o %PPID -x ${DAEMON}`
	if [ -n "${PIDLIST}" ];
	then
		echo "${DAEMON} (pid ${PIDLIST}) is running"
		return ${STATUS_RUNNING}
	fi

	# Check for pid file in standard location
	PIDFILE="/opt/dell/srvadmin/iSM/var/run/${DAEMON}.pid"
	if [ -f ${PIDFILE} ];
	then
		echo "${DAEMON} is dead and /opt/dell/srvadmin/iSM/var/run pid file exists"
		return ${STATUS_DEAD_PIDFILE_EXISTS}
	fi

	# Check for lock file in standard location
	LOCKFILE="${OS_SUBSYS_LOCK_DIR}/${daemon}"
	if [ -f ${LOCKFILE} ];
	then
		echo "${DAEMON} is dead and /opt/dell/srvadmin/iSM/var/lock lock file exists"
		return ${STATUS_DEAD_LOCKFILE_EXISTS}
	fi

	echo "${DAEMON} is stopped"
	return ${STATUS_NOT_RUNNING}
} # dcismeng_supt_daemonstatus


###############################################################################
# Function:    dcismeng_supt_showsuccess <message>
# Description: Display service success message
# Returns:     none
###############################################################################
dcismeng_supt_showsuccess()
{
	MSG="$1"

	if [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_LSB} ];
	then
		log_success_msg "${MSG}"
	elif [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_RH} ];
	then
		echo -n "${MSG}"
		echo_success
		echo
	else
		echo -n "${MSG}"
		echo -en \\033[45G
		echo "OK"
	fi
} # dcismeng_supt_showsuccess


###############################################################################
# Function:    dcismeng_supt_showfailure <message>
# Description: Display service failure message
# Returns:     none
###############################################################################
dcismeng_supt_showfailure()
{
	MSG="$1"

	if [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_LSB} ];
	then
		log_failure_msg "${MSG}"
	elif [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_RH} ];
	then
		echo -n "${MSG}"
		echo_failure
		echo
	else
		echo -n "${MSG}"
		echo -en \\033[45G
		echo "FAILED"
	fi
} # dcismeng_supt_showsuccess


###############################################################################
# Function:    dcismeng_supt_showwarning <message>
# Description: Display service warning message
# Returns:     none
###############################################################################
dcismeng_supt_showwarning()
{
	MSG="$1"

	if [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_LSB} ];
	then
		log_warning_msg "${MSG}"
	elif [ ${OS_SCRIPT_FUNCTIONS} = ${OS_SCRIPT_FUNCTIONS_RH} ];
	then
		echo -n "${MSG}"
		echo_warning
		echo
	else
		echo -n "${MSG}"
		echo -en \\033[45G
		echo "WARNING"
	fi
} # dcismeng_supt_showwarning


###############################################################################
# Function:    dcismeng_supt_logmessage <message>
# Description: Log message to OS log
# Returns:     none
###############################################################################
dcismeng_supt_logmessage()
{
	MSG="$1"

	# Log message to OS log
	logger -t "${ISM_SCRIPT_NAME}" "${MSG}"
} # dcismeng_supt_logmessage


###############################################################################
# End Functions
###############################################################################


###############################################################################
# Check command line parameter for action to perform
###############################################################################

case "$1" in
	start)
		# start service
		dcismeng_start
		EXIT_STATUS=$?
		;;

	stop)
		# stop service
		dcismeng_stop
		EXIT_STATUS=$?
		;;

	restart|force-reload)
		# restart service
		dcismeng_stop
		dcismeng_start
		EXIT_STATUS=$?
		;;

	status)
		# print and return current status of service
		dcismeng_status
		EXIT_STATUS=$?
		;;

	status-quiet)
		# return current status of service
		dcismeng_status >/dev/null
		EXIT_STATUS=$?
		;;


	reload)
		# reload configuration
		echo "${ISM_SCRIPT_NAME}: reload not supported"
		EXIT_STATUS=${STATUS_NOT_IMPLEMENTED}
		;;


	startdaemon|startd)
		# start iSM daemon
		dcismeng_startdaemon "$2"
		EXIT_STATUS=$?
		;;

	stopdaemon|stopd)
		# stop iSM daemon
		dcismeng_stopdaemon "$2"
		EXIT_STATUS=$?
		;;

	restartdaemon|restartd)
		# restart iSM daemon
		dcismeng_stopdaemon "$2"
		dcismeng_startdaemon "$2"
		EXIT_STATUS=$?
		;;

	*)
		echo "${DENG_SCRIPT_NAME}: Invalid argument"
		echo "Usage: ${DENG_SCRIPT_NAME} {start|stop|restart|force-reload|status}"
		EXIT_STATUS=${STATUS_INVALID_ARG}
esac

exit ${EXIT_STATUS}


###############################################################################
# End Script
###############################################################################

