#!/bin/sh
#
# Start/Stop GlobeCom services
##############################
# /etc/init.d/glbservices #
##############################
####################
### Subroutines ###
####################
### Start Apache Strong Hold ###
#Apache_server () {
# clear
# echo ""
# echo " Restart apache ..."
# /usr/local/apache/bin/stop-server 2> /dev/null
# sleep 2
# /usr/local/apache/bin/start-server 2>/dev/null
#}
### Start Apache Freeware ###
Apache_server () {
clear
echo ""
echo " Restart apache ..."
/usr/local/apache/bin/apachectl stop 2> /dev/null
sleep 2
/usr/local/apache/bin/apachectl graceful 2> /dev/null
}
### Start Npdd (LSM) ###
Npdd () {
clear
echo ""
echo " Restart npdd (LSM)..."
kill_proc "${GLOBECOM_DIR}/bin/npdd"
kill_proc "${GLOBECOM_DIR}/bin/Lsm"
/usr/local/gwa/bin/Npdd
}
### Start IsAlive ###
IsAlive () {
clear
echo ""
echo " Restart IsAlive ..."
kill_proc "${GLOBECOM_DIR}/bin/startIsAlive.sh"
/usr/local/gwa/bin/startIsAlive.sh &
}
### Start TrapsFilter ###
TrapsFilter () {
clear
grep "nms ip=" /usr/local/gwa/conf/trace.conf | grep "\." > /dev/null
if [ "$?" = "0" ]
then
echo ""
echo " Restart TrapsFilter ..."
kill_proc "${GLOBECOM_DIR}/bin/startTrapsFilter.sh"
/usr/local/gwa/bin/startTrapsFilter.sh &
fi
}
### Start FES ###
FES () {
clear
echo ""
echo " Restart FES ..."
kill_proc "${GLOBECOM_DIR}/bin/FES"
/usr/local/gwa/bin/startFES.sh &
}
### Start sdu ###
Sdu () {
clear
echo ""
echo " Restart sdu ..."
kill_proc "${GLOBECOM_DIR}/bin/sdud"
/usr/local/gwa/bin/sdud
}
### Start sda ###
Sda () {
clear
echo ""
echo " Restart sda ..."
kill_proc "${GLOBECOM_DIR}/bin/sdad"
/usr/local/gwa/bin/sdad
}
### Start Weblogic ###
Weblogic () {
clear
echo ""
echo " Restart Weblogic ..."
/etc/init.d/wlsrv stop
sleep 5
/etc/init.d/wlsrv start
}
# Kill all processes matching a certain name
kill_proc () {
ps -ef | grep "$1" | grep -v grep | while read PROC; do \
PID=`echo ${PROC} | awk '{ print $2 }'`
[ ${PID} -gt 0 ] && kill -9 ${PID}
done
}
####################
### Main script ###
####################
# Set environment
PATH=/usr/local/gwa/bin:.:$PATH
export PATH
LD_LIBRARY_PATH=/usr/local/gwa/lib:/usr/local/lib:/usr/ucblib
export LD_LIBRARY_PATH
GLOBECOM_DIR=/usr/local/gwa
export GLOBECOM_DIR
MODE_FILE=/usr/local/gwa/conf/glbservices.conf
MODE=`cat $MODE_FILE`
case "$1" in
start)
if [ "$MODE" = "n" ]
then
echo ""
elif [ "$MODE" = "a" ]
then
Apache_server
elif [ "$MODE" = "e" ]
then
FES
Apache_server
elif [ "$MODE" = "f" ]
then
Weblogic
TrapsFilter
elif [ "$MODE" = "w" ]
then
Weblogic
elif [ "$MODE" = "b" ]
then
Apache_server
Weblogic
elif [ "$MODE" = "t" ]
then
Apache_server
Weblogic
TrapsFilter
else
# -- Usage --
echo ""
echo "Missing/incorrect "$SMODE_FILE
echo "Valid modes are: "
echo " n - Do nothing"
echo " a - Restart Apache"
echo " e - Restart Apache, FES"
echo " w - Restart Weblogic"
echo " f - Restart Weblogic, TrapsFilter"
echo " b - Restart Weblogic, Apache"
echo " t - Restart Weblogic, TrapsFilter, apache"
exit 1
fi
echo "Globecom services started."
;;
stop)
/usr/local/apache/bin/apachectl stop 2> /dev/null
/etc/init.d/wlsrv stop
kill_proc "java"
kill_proc "/bin/sh ${GLOBECOM_DIR}/bin/startTrapsFilter.sh"
kill_proc "/bin/sh ${GLOBECOM_DIR}/bin/startFES.sh"
echo "Globecom services stopped."
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0