#!/bin/bash # # Copyright 2003-2018 Broadcom. All Rights Reserved. # The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. # # This script may be executed as follows: # # stop_ocmanager [-r | -n | -g | -w ] # # The following table describes the affect each of these arguments # has on the the various OCManager related components. # # |-----|-----|-----|-----|------| # | -r | -n | -g | -w | none | # |---------------------------|-----|-----|-----|-----|------| # | Stop Discovery daemon | N | Y | Y | N | Y | # |---------------------------|-----|-----|-----|-----|------| # | Stop elxhbamgrd (rmserver)| Y | N | Y | Y | Y | # |---------------------------|-----|-----|-----|-----|------| # | Stop OCManager GUI | N | Y | N | N | Y | # |---------------------------|-----|-----|-----|-----|------| # | Remove Semaphore dir | N | Y | N | N | Y | # |---------------------------|-----|-----|-----|-----|------| # | Stop SNMP daemon | N | N | N | N | Y | # |---------------------------|-----|-----|-----|-----|------| discoveryDaemonStopped=0 sles_major_version="0" systemd_elxhbamgr=usr/lib/systemd/system/elxhbamgrd.service systemd_elxdisco=usr/lib/systemd/system/elxdiscoveryd.service systemd_elxsnmp=usr/lib/systemd/system/elxsnmpd.service init_elxhbamgr=etc/init.d/elxhbamgrd init_elxdisco=etc/init.d/elxdiscoveryd init_elxsnmp=etc/init.d/elxsnmpd platform_os=`uname -s` if [ "$platform_os" = "Linux" ];then INSTALL_DIR="usr/sbin/ocmanager" else INSTALL_DIR="opt/ELXocm" fi # Kill parent elxhbamgrd # If -n argument was passed to script, then don't kill the elxhbamgrd if [ "$1" != "-n" ]; then if [ "$platform_os" = "Linux" ];then if [ -x /${init_elxhbamgr} ]; then /${init_elxhbamgr} stop elif [ -f /${systemd_elxhbamgr} ]; then echo "Stopping elxhbamgrd (via systemctl):" systemctl stop elxhbamgrd.service else echo "Unable to stop elxhbamgrd!" fi else # Solaris # Temporarily (until the next reboot) stop the elxhbamgrd daemons svcadm disable -st application/elxhbamgrd fi fi # If request was to stop elxhbamgrd only, then exit now. if [ "$1" = "-r" ] || [ "$1" = "-w" ]; then exit fi # Kill OneCommand Manager GUI if [ "$1" != "-g" ]; then # Get pid of script that started the OneCommand Manager GUI script_pid=`ps -eaf | grep ocmanager | grep "/bin/bash" | grep -v grep | head -n 1 | awk '{ print $2 }'` # echo "script pid of "/ocmanager" is $script_pid" if [ "$script_pid" != "" ]; then gui_pid=`ps -eaf | grep java | grep -v grep | grep "/OCManager.jar" | awk '{ print $2 }'` if [ "$gui_pid" != "" ]; then echo "Stopping the OneCommand Manager GUI" if [ "$platform_os" = "Linux" ];then kill -9 $gui_pid > /dev/null 2>&1 else kill $gui_pid > /dev/null 2>&1 fi fi fi fi if [ "$platform_os" = "Linux" ]; then if [ "$1" != "-r" ] && [ "$1" != "-w" ]; then # Kill parent elxdiscoveryd if [ -x /${init_elxdisco} ]; then /${init_elxdisco} stop elif [ -f /${systemd_elxdisco} ]; then echo "Stopping elxdiscoveryd (via systemctl):" systemctl stop elxdiscoveryd.service fi fi else # Solaris # Stop the start-elxdiscoveryd service. No need to restart it in start_ocmanager # since this service doesn't do anything after boot. svcadm disable -t application/start-elxdiscoveryd > /dev/null 2>&1 # Temporarily (until the next reboot) stop the elxdiscoveryd daemon svcadm disable -st application/elxdiscoveryd > /dev/null 2>&1 fi # remove HBA semaphore (POSIX named semaphores) if [ "$platform_os" = "Linux" ]; then if [ "$1" != "-g" ]; then rm -f /dev/shm/sem.ElxHbaSem* fi else /opt/ELXocm/freesem > /dev/null 2>&1 fi # get sles11 indicator if [ -f /etc/SuSE-release ]; then sles_major_version=`cat /etc/SuSE-release | grep VERSION | awk '{ print $3 }'` fi # if no arguments were used if [ $# -eq 0 ]; then # stop the SNMP Daemon ppid=`ps -ea | grep '[BE2|ELX]SNMP' | grep -v grep | awk '{ print $1 }' | sort -n | head -n 1` if [ -x /${init_elxsnmp} ]; then if [ ! -z "$ppid" ]; then /${init_elxsnmp} stop else /${init_elxsnmp} stop > /dev/null 2>&1 fi elif [ -f /${systemd_elxsnmp} ]; then echo "Stopping elxsnmpd (via systemctl):" systemctl stop elxsnmpd.service fi if [ "$platform_os" = "Linux" ]; then # stop the ocv sensor daemons if necessary if [ -x "/usr/local/elx/ocvsensor/stop-sensor" ]; then /usr/local/elx/ocvsensor/stop-sensor fi else # Solaris # stop the ocv sensor daemons if necessary if [ -x "/opt/elx/OCVsensor/stop-sensor" ]; then /opt/elx/OCVsensor/stop-sensor fi fi fi exit 0