#!/usr/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/sa/dhcp/sbin/cl_dhcp_stop.sh 1.1 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2010 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)61 1.1 src/43haes/usr/sbin/cluster/sa/dhcp/sbin/cl_dhcp_stop.sh, hacmp, 61haes_r714 11/28/11 15:24:12 ############################################################################### # # Name: cl_dhcp_stop # # Description: Command used as the PowerHA SystemMirror Application Server # "Stop Script" for DHCP. # # Syntax: cl_dhcp_stop # # Arguments: N/A # # Returns: 0 on SUCCESS # 1 on FAILURE # ############################################################################### . /usr/es/lib/ksh93/func_include ############################################################################### # # Name: isRunning # # Description: Check to see if DHCP server dhcpsd daemon is active. # # Arguments: none # # Returns: 0 on RUNNING # 1 on NOT RUNNING # ################################################################################ function isRunning { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x # : DHCP daemon - dhcpsd is active or not # KLIB_SA_logmsg INFO 3 1 dhcpsa.cat "Verifying to see DHCP server daemon dhcpsd is active." LC_ALL=C /usr/bin/lssrc -s dhcpsd | /usr/bin/grep -iw active >> $LOG_FILE 2>&1 if (( $? == 0 )); then KLIB_SA_logmsg INFO 3 2 dhcpsa.cat "DHCP server daemon dhcpsd is active" return 0 else KLIB_SA_logmsg INFO 3 3 dhcpsa.cat "DHCP server daemon dhcpsd is not active" return 1 fi } ############################################################################### # # Name: doStop # # Description: Stops the DHCP server daemon dhcpsd. # # Arguments: none # # Returns: 0 on SUCCESS # 1 on FAILURE # ################################################################################ function doStop { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x # : Stops the DHCP server daemon dhcpsd # /usr/bin/stopsrc -s dhcpsd >> $LOG_FILE 2>&1 sleep 5 # : Check the status of DHCP server daemon dhcpsd # isRunning (( $? == 0 )) && { KLIB_SA_logmsg ERROR 4 1 dhcpsa.cat "DHCP server daemon dhcpsd \ has not been stopped" return 1 } KLIB_SA_logmsg INFO 4 2 dhcpsa.cat "DHCP server daemon dhcpsd has been stopped" return 0 } ############################################################################### # Main program procedure. ############################################################################### PROGNAME=$(basename ${0}) PATH="$($(dirname ${0})/../../../utilities/cl_get_path all)" PATH=$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin FPATH_BASE=/usr/es/lib/ksh93 FPATH=$FPATH_BASE/hacmp:$FPATH_BASE/sa:$FPATH_BASE/aix:$FPATH_BASE/aix/odm export PATH FPATH # : Load the common variables # . /usr/es/sbin/cluster/sa/dhcp/sbin/cl_dhcp_common_variables LOG_FILE=$(clodmget -q name=$KLIB_HACMPLOG_ENTRY -f value -d "=" HACMPlogs) LOG_FILE=${LOG_FILE//\"/} LOG_FILE="$LOG_FILE/$KLIB_HACMPLOG_ENTRY" [[ "$VERBOSE_LOGGING" == "high" ]] && set -x DEBUG=${DEBUG:-"0"} VERBOSE=${VERBOSE:-"0"} echo "######################################################" >> $LOG_FILE dspmsg -s 4 dhcpsa.cat 3 "# DHCP STOP LOG" >> $LOG_FILE echo "######################################################" >> $LOG_FILE # : Check the status DHCP server daemon dhcpsd # isRunning (( $? == 0 )) && { KLIB_SA_logmsg INFO 4 4 dhcpsa.cat "Stopping DHCP server daemon dhcpsd" # : DHCP server daemon dhcpsd is active. : Make an attempt to stop. # doStop exit $? } exit 0