File: //opt/OV/lbin/ctrl/OVCtrl
#!/bin/sh
#
# @(#)BegWS :1.0
# @(#)CR :(c) Copyright 2001-2017 Hewlett-Packard Enterprise Development Company, L.P.
# @(#)Name :HPE Software Control
# @(#)Ver :12.05.006
# @(#)FileN :OVCtrl
# @(#)FileV :12.05.006
# @(#)Rtype :Released
# @(#)CBID :2017-11-16_1500
# @(#)OS :Linux
# @(#)OSV :2.6
# @(#)Arch :x64
# @(#)Bits :64
# @(#)Desc :HPE Software Control Script
# @(#)Patch :
# @(#)Build :0000
# @(#)EndWS :
#
#!/bin/sh
# chkconfig: 35 99 1
### BEGIN INIT INFO
# Provides: OVCtrl
# Required-Start: $network
# Required-Stop: $network
# Should-Start: $ALL
# Should-Stop: $ALL
# Default-Start: 3 5
# Default-Stop: 0 6
# Description: Start the OVCtrl application
### END INIT INFO
##Added this section for CR QCCR1A190325
targetval=$1
## Added this ection for only Linux CR 175474
if [ -f /etc/profile ]
then
. /etc/profile
fi
SCRIPT_NAME="$0"
NAMESPACE="ctrl"
ATTRIBUTE="START_ON_BOOT"
ATTRIBUTE_RUN="RUN_PROFILE"
SERVICE_NAME="OVCtrl"
ATTRIBUTE_INT="START_CHK_INTERVAL"
OV_BIN="/opt/OV/bin"
SU_VAR="/bin/su"
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin;export PATH;
usage()
{
echo "USAGE: OVCtrl start|stop|restart|START|STOP|enable|disable|status" 1>&2
exit 1
}
is_ovc_running()
{
sleep 1
PSCOUNT=`ps -ef | egrep -e ' ovc -' -e '/ovc -' | grep -v grep | wc -l`
PSCOUNT1=`ps -ef | egrep -e ' ovc -' | grep -v grep | wc -l`
PSCOUNT2=`ps -ef | egrep -e ' ovc ' | grep -v grep | wc -l`
if [ $PSCOUNT -eq 0 -a $PSCOUNT1 -eq 0 -a $PSCOUNT2 -eq 0 ]
then
return 0
else
return 1
fi
}
IsSELinuxEnabled()
{
[ ! -d /etc/selinux ] && return 1
[ ! -f /etc/selinux/config ] && return 1
typeset -i lcount=`grep -c -e '^ *SELINUX=disabled' /etc/selinux/config`
[ $lcount -ne 0 ] && return 1
typeset -i lcount=`grep -c -e '^ *SELINUX=enforcing' -e '^ *SELINUX=permissive' /etc/selinux/config`
[ $lcount -ne 0 ] && return 0
}
start_service()
{
OASTARTDELAY=`$OV_BIN/ovconfget ctrl START_WITH_DELAY` 2>/dev/null
if [[ $OASTARTDELAY > 0 ]]; then
#ovconfchg -ns ctrl -set START_WITH_DELAY 30
#Start OA after 30 secs
echo "Start OA service after $OASTARTDELAY sec"
sleep $OASTARTDELAY
fi
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE`" = "true" ]
then
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_RUN`" = "true" ]
then
if IsSELinuxEnabled
then
if [ -f /sbin/runuser ]
then
/sbin/runuser - root -c "/opt/OV/bin/ovc -start -boot"
else
/bin/su - root -c "/opt/OV/bin/ovc -start -boot"
fi
else
/bin/su - root -c "/opt/OV/bin/ovc -start -boot"
fi
RETVAL=$?
else
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export PATH;$OV_BIN/ovc -start -boot
RETVAL=$?
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/OVCtrl
echo
sleep 3
return $RETVAL
else
echo "The service $SERVICE_NAME has been disabled. Please run the command '$SCRIPT_NAME enable' to enable it or use '
$SCRIPT_NAME [START|STOP]' to start or stop the service manually."
fi
}
stop_service()
{
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE`" = "true" ]
then
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_RUN`" = "true" ]
then
if IsSELinuxEnabled
then
if [ -f /sbin/runuser ]
then
/sbin/runuser - root -c "/opt/OV/bin/ovc -kill"
else
/bin/su - root -c "/opt/OV/bin/ovc -kill"
fi
else
/bin/su - root -c "/opt/OV/bin/ovc -kill"
fi
RETVAL=$?
else
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export PATH;$OV_BIN/ovc -kill
RETVAL=$?
fi
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/OVCtrl
echo
return $RETVAL
else
echo "The service $SERVICE_NAME has been disabled. Please run the command '$SCRIPT_NAME enable' to enable it or use '
$SCRIPT_NAME [START|STOP]' to start or stop the service manually."
fi
}
restart_service()
{
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE`" = "true" ]
then
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_RUN`" = "true" ]
then
if IsSELinuxEnabled
then
if [ -f /sbin/runuser ]
then
/sbin/runuser - root -c "/opt/OV/bin/ovc -restart"
else
/bin/su - root -c "/opt/OV/bin/ovc -restart"
fi
else
/bin/su - root -c "/opt/OV/bin/ovc -restart"
fi
return $?
else
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export PATH;$OV_BIN/ovc -restart
return $?
fi
else
echo "The service $SERVICE_NAME has been disabled. Please run the command '$SCRIPT_NAME enable' to enable it or use '
$SCRIPT_NAME [START|STOP]' to start or stop the service manually."
fi
}
enable_service()
{
if ! $OV_BIN/ovconfchg -ns $NAMESPACE -set $ATTRIBUTE true
then
echo "Unable to set the required settings to enable the service $SERVICE_NAME." 1>&2
return 1
else
echo "The service $SERVICE_NAME is now enabled and will be started during the next bootup."
return 0
fi
}
disable_service()
{
if ! $OV_BIN/ovconfchg -ns $NAMESPACE -set $ATTRIBUTE false
then
echo "Unable to set the required settings to disable the service $SERVICE_NAME." 1>&2
return 1
else
echo "The service $SERVICE_NAME is now disabled and will not be started during the next bootup."
return 0
fi
}
if [ $# -ne 1 ]; then
usage
fi
count=1
retval_ovc_chk=1
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_INT`" ]
then
start_chk_interval=`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_INT`
else
start_chk_interval=180
fi
while [ $retval_ovc_chk -ne 0 ]
do
if [ $count -gt $start_chk_interval ]
then
echo "ovc instance still running ..proceeding further"
break
fi
count=`expr $count + 1`
is_ovc_running
retval_ovc_chk=$?
done
case $targetval in
start_msg)
echo "Starting Control Daemon"
;;
stop_msg)
echo "Stopping Control Daemon"
;;
'start')
start_service
;;
'stop')
stop_service
;;
'restart')
restart_service
;;
START)
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE`" = "true" ]
then
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_RUN`" = "true" ]
then
if IsSELinuxEnabled
then
if [ -f /sbin/runuser ]
then
/sbin/runuser - root -c "/opt/OV/bin/ovc -start -boot"
else
/bin/su - root -c "/opt/OV/bin/ovc -start -boot"
fi
else
/bin/su - root -c "/opt/OV/bin/ovc -start -boot"
fi
exit $?
else
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export PATH;$OV_BIN/ovc -start -boot
exit $?
fi
fi
;;
STOP)
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE`" = "true" ]
then
if [ "`$OV_BIN/ovconfget $NAMESPACE $ATTRIBUTE_RUN`" = "true" ]
then
if IsSELinuxEnabled
then
if [ -f /sbin/runuser ]
then
/sbin/runuser - root -c "/opt/OV/bin/ovc -kill"
else
/bin/su - root -c "/opt/OV/bin/ovc -kill"
fi
else
/bin/su - root -c "/opt/OV/bin/ovc -kill"
fi
exit $?
else
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin;export PATH; $OV_BIN/ovc -kill
exit $?
fi
fi
;;
enable)
enable_service
exit $?
;;
disable)
disable_service
exit $?
;;
status)
$OV_BIN/ovc -status
exit $?
;;
*)
usage
;;
esac