TOMCAT START/STOP#!/bin/bash## tomcat This shell script takes care of starting and stopping Tomcat## chkconfig: - 80 20#### BEGIN INIT INFO# Provides: tomcat# Required-Start: $network $syslog# Required-Stop: $network $syslog# Default-Start:# Default-Stop:# Short-Description: start and stop tomcat### END INIT INFOTOMCAT_USER=liferayappTOMCAT_HOME="/opt/liferay/tomcat-7.0.27"SHUTDOWN_WAIT=45tomcat_pid() {echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`}start() {pid=$(tomcat_pid)if [ -n "$pid" ]thenecho "Tomcat is already running (pid: $pid)"else# Start tomcatecho "Starting tomcat"/bin/su - -c "cd $TOMCAT_HOME/bin && $TOMCAT_HOME/bin/startup.sh" $TOMCAT_USERfireturn 0}stop() {pid=$(tomcat_pid)if [ -n "$pid" ]thenecho "Stoping Tomcat"/bin/su - -c "cd $TOMCAT_HOME/bin && $TOMCAT_HOME/bin/shutdown.sh" $TOMCAT_USERlet kwait=$SHUTDOWN_WAITcount=0count_by=5until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]doecho "Waiting for processes to exit. Timeout before we kill the pid: ${count}/${kwait}"sleep $count_bylet count=$count+$count_by;doneif [ $count -gt $kwait ]; thenecho "Killing processes which didn't stop after $SHUTDOWN_WAIT seconds"kill -9 $pidfielseecho "Tomcat is not running"fireturn 0}case $1 instart)start;;stop)stop;;restart)stopstart;;status)pid=$(tomcat_pid)if [ -n "$pid" ]thenecho "Tomcat is running with pid: $pid"elseecho "Tomcat is not running"fi;;esacexit 0STARTING STOPPING WEBLOGIC ADMIN SERVER#!/bin/sh if [ -z "$1" ]; then echo "You must supply either start or stop command while calling this script! correct usage: weblogic_start_stop.sh start|stop" exit fi bold=`tput bold` normal=`tput sgr0` case "$1" in 'start') echo "Starting Management Node & Weblogic Server 10.3.6" echo "Starting NodeManager" nohup $WLS_HOME/server/bin/startNodeManager.sh > /dev/null 2>&1 & sleep 10 output=`ps -ef | grep -i nodemanager.javahome | grep -v grep | awk {'print $2'} | head -1` set $output pid=$1 echo "Weblogic NodeManager Service was started with process id : ${bold}$pid${normal}" echo "Starting WebLogic Domain" nohup $MW_HOME/user_projects/domains/ClassicDomain/bin/startWebLogic.sh > /dev/null 2>&1 & # Sleep until exiting sleep 60 echo "All done, exiting" exit esac ################################Stopping the services################################## case "$1" in 'stop') echo "Stopping Weblogic Server & Node Manager" nohup $MW_HOME/user_projects/domains/ClassicDomain/bin/stopWebLogic.sh > /dev/null 2>&1 & sleep 30 # echo "Killing Nodemanager process now" output=`ps -ef | grep -i nodemanager.javahome | grep -v grep | awk {'print $2'} | head -1` set $output pid=$1 echo "Killing Weblogic NodeManager Service Process : ${bold}$pid${normal}" kill -9 `ps -ef | grep -i nodemanager.javahome | grep -v grep | awk {'print $2'} | head -1` echo "All done, exiting" exit esac
Tuesday, January 20, 2015
sampleshellscripting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment