#!/bin/sh ###################################################################################### # weblogic - Bea Weblogic 8.1 start/stop System V init script. # # # # Usage: Place this script in /etc/init.d/ (Linux). Don't forget to create # # a symbolic link in the current runlevel's start directory to run # # this script on system boot. Use weblogic.Admin with the # # STOREUSERCONFIG command to properly store user credentials. # # # # Version 1.0 Created April 20, 2006 by Jeff Schroeder (jeffschroeder@computer.org) # # License: GNU GPL 2 ONLY. See http://www.fsf.org/licensing/licenses/info/GPLv2.html # # # ###################################################################################### # Debugging: Disabled by default. #set -x export PATH=$PATH:/bea/jrockit81sp5_142_08/bin export CLASSPATH=/bea/weblogic81/server/lib/weblogic.jar WL_BIN_DIR=/bea/weblogic81/server/bin WL_DOM_HOME=/bea/user_projects/domains/portalDomain # Domain home directory USERNAME=www # Username that weblogic runs as ADMIN_URL=localhost:7001 # Admin server URL ADMIN_NAME=portalServer # Admin server name admin_server_check() { # Is the Weblogic Administration Server running? # if (java weblogic.Admin -url $ADMIN_URL GETSTATE | egrep 'RUNNING|STANDBY' >/dev/null 2>&1); then # Only works if STOREUSERCONFIG is ran as this user so using weblogic.Admin is buggy. if (ps aux | egrep "Name=$ADMIN_NAME.*weblogic.Server$" >/dev/null 2>&1); then ADMIN_PID=$(pgrep -f "Name=$ADMIN_NAME.*weblogic.Server$") ADMIN_RUNNING=yes else ADMIN_RUNNING=no fi } node_manager_check() { # Is NodeManager running? if (pgrep -f weblogic.NodeManager$ >/dev/null 2>&1); then NM_PID=$(pgrep -f weblogic.NodeManager$) NM_RUNNING=yes else NM_RUNNING=no fi } admin_server_control() { case "$1" in start) if [ $ADMIN_RUNNING = no ]; then cd $WL_DOM_HOME sudo -u $USERNAME $WL_DOM_HOME/startWebLogic.sh nopointbase production & else echo 'Administration Server already running!' fi ;; stop) if [ $ADMIN_RUNNING = yes ]; then #$WL_DOM_HOME/stopWebLogic.sh weblogic kill $ADMIN_PID else echo 'Administration Server is not running, nothing to stop!' fi ;; restart) if [ $ADMIN_RUNNING = yes ]; then kill $ADMIN_PID sleep 3 sudo -u $USERNAME $WL_DOM_HOME/startWebLogic.sh nopointbase production & elif [ $ADMIN_RUNNING = no ]; then echo 'NOTICE: Administration Server is not running, attempting to start!' cd $WL_DOM_HOME sudo -u $USERNAME $WL_DOM_HOME/startWebLogic.sh & fi ;; status) if [ $ADMIN_RUNNING = yes ]; then echo -e "Admin Server running \tPID = $ADMIN_PID \tUSER = $(ps -fp $ADMIN_PID | awk '/java/{print $1}')" elif [ $ADMIN_RUNNING = no ]; then echo 'Admin Server not running!' fi ;; esac } nodemanager_control() { case "$1" in start) if [ $NM_RUNNING = no ]; then cd $WL_BIN_DIR sudo -u $USERNAME $WL_BIN_DIR/startNodeManager.sh >/dev/null & else echo 'NodeManager is already running!' fi ;; stop) if [ $NM_RUNNING = yes ]; then kill $NM_PID else echo 'NodeManager is not running, nothing to stop!' fi ;; restart) if [ $NM_RUNNING = yes ]; then kill $NM_PID sleep 3 cd $WL_BIN_DIR sudo -u $USERNAME $WL_BIN_DIR/startNodeManager.sh >/dev/null & elif [ $NM_RUNNING = no ]; then cd $WL_BIN_DIR sudo -u $USERNAME $WL_BIN_DIR/startNodeManager.sh >/dev/null & fi ;; status) if [ $NM_RUNNING = yes ]; then echo -e "Node Manager running \tPID = $NM_PID \tUSER = $(ps -fp $NM_PID 2>/dev/null | awk '/java/{print $1}')" elif [ $NM_RUNNING = no ]; then echo 'NodeManager not running!' fi ;; esac } # Main program starts here if [ $# != 0 ]; then admin_server_check node_manager_check fi # Comment out the Admin Server lines below if this server is only running Node Manager. case "$1" in start) admin_server_control $1 nodemanager_control $1 ;; stop) admin_server_control $1 nodemanager_control $1 ;; status) admin_server_control $1 nodemanager_control $1 ;; restart) admin_server_control $1 nodemanager_control $1 ;; *) echo "Usage: $(dirname $0)/$(basename $0) start|stop|status|restart" exit 1 ;; esac