linus上自动部署shell脚步

#!/bin/sh
#stop server
echo "Start to stop tomcat......";
sh ${CATALINA_HOME}/cfg/eeducation.sh stop ;
sleep 3
sh ${CATALINA_HOME}/cfg/eeducation.sh status ;
#zip the exists files to *.war
echo "Start to zip the exist files......" ;
cd $CATALINA_HOME/webapps/ ;
jar -cf manager.war ./manager ;
echo "Start to backup *.war ......";
mkdir ~/upgrade_bak/ ;
cp -f ./manager.war  ~/upgrade_bak/ ;
#delete dircetory in webapps
echo "Start to delete directorys......";
rm -rf $CATALINA_HOME/webapps/manager ;
rm -rf $CATALINA_HOME/webapps/manager.war ;
rm -rf $CATALINA_HOME/work;
#unzip *.war 
echo "Start to unzip directorys......";
mkdir $CATALINA_HOME/webapps/manager ;
cd $CATALINA_HOME/webapps/manager ;
jar -xf  ~/upgrade/manager.war ;
#replace special files 
echo "Start to replace special files......";
cp -f ~/upgrade/config.xml $CATALINA_HOME/webapps/manager/WEB-INF/classes ;
# start server
echo "Start to start tomcat......";
sh ${CATALINA_HOME}/cfg/eeducation.sh start ;
tail -f ${CATALINA_HOME}/logs/catalina.out ;
 

 

 

#!/bin/sh

INST_DIR="${CATALINA_HOME}"
IREAD_USER=`whoami`
SCRIPT_NAME=`basename $0`
LOG_FILE="${CATALINA_HOME}/logs/ireadtrace.log"
SERVICE=Manager

killadapter()
{
    # list pids of the iread processes
    pids=`ps -fu  ${IREAD_USER} | grep "java" | grep -v "grep" | awk '{print $2}'`
    if [ -n "$pids" ]; then
      kill -9 $pids
    else
        echo "iRead process does not exist!"
        echo "iRead process does not exist!" >>${LOG_FILE}
    fi
}

start()
{
    # list pids of the iread processes
    pids=`ps -fu ${IREAD_USER} | grep "java" | grep -v "grep" | awk '{print $2}'`
    if [ -n "$pids" ]; then
       echo "$SERVICE already running."
       echo "$SERVICE already running." >>${LOG_FILE}
       exit 0
    fi
    if [ -e ${LOG_FILE} ]; then
        mv ${LOG_FILE} ${LOG_FILE}.bak
    fi
    echo "starting $SERVICE at: `date`.."
    echo "starting $SERVICE at: `date`.." >>${LOG_FILE}
    cd ${CATALINA_HOME}
    bin/startup.sh 2>&1 >>${LOG_FILE} &
}

stop()
{
     echo "stopping $SERVICE at: `date`"
     echo "stopping $SERVICE at: `date`">>${LOG_FILE}
     killadapter
}


status()
{
    # list pids of the iread processes
    pids=`ps -f U ${IREAD_USER} | grep "java" | grep -v "grep"`

    if [ -n "$pids" ]; then
        echo "$SERVICE is running"
        echo "$SERVICE is running" >>${LOG_FILE}
              exit 0
    fi
    echo $SERVICE is stopped
    exit 3
}


restart()
{
    stop
    sleep 5
    start
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        status
        ;;
        -h|-help|--h|--help|help)
        echo "Usage: $SCRIPT_NAME {start|stop|restart|status|-h|-help|--help|help}"
        exit 0
        ;;
  *)
        echo "Usage: $SCRIPT_NAME {start|stop|restart|status|-h|-help|--help|help}"
        exit 1
esac

exit 0
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值