posted by 은이종 은이종 2014. 11. 12. 18:53


 가끔 필요할 때가 있어서 스크립트 생성해보았습니다.

Instance 변경시 주의해야할 점은
1. Instance 폴더 변경
2. 사용하는 Docroot / Deploy 쪽 폴더 변경
3. 구동 및 정지 배치파일
4. loging, server.xml, 등 설정 파일 변경

파일명은 간단히 change_instance.sh

 
처음에 설정하는 디렉토리명 등 상황에 맞춰서 설정 후 사용하면 됩니다. 

================================================================================



#!/bin/sh

## 디렉토리명 설정##
FORCE=0
[ ! -z $1 ] && [ "$1" == "-f" ] && FORCE=1
[ ! -z $1 ] && [ "$1" == "-ff" ] && FORCE=2
APPNAME=tomcat
APP_PREFIX=/app/tomcat
DOCROOT=/app/docroot
DEPLOY=/app/deploy

echo
echo "============================= "
echo "Java 실행중인지 체크!!!!!     "
echo "============================= "
echo

ps aufx | grep svr_*

echo; echo
echo "============================= "
read -p "실행 중인지 확인됐나요?"
echo "============================= "
echo "Tomcat Instacne Check!! Enter "
echo "============================= "

/bin/ls -l $APP_PREFIX/ | grep svr_*

echo "=============================="
echo " Now Intance, Chagne Instance "
echo " Now : " & read l
echo " Change : " & read i
echo "============================"
echo " N  o w : $l"
echo " Change : $i"
echo "============================"

if [ $FORCE -lt 1 ];then
    read -p "Are you Continue [y/N] : " cont
    if ! [ "0$cont" == "0Y" -o "0$cont" == "0y" ];then
        echo "Bye~!"
        exit 1
    fi
fi

mv ${APP_PREFIX}/${l} ${APP_PREFIX}/${i}
mv ${DOCROOT}/${APPNAME}/${l} ${DOCROOT}/${APPNAME}/${i}
mv ${DEPLOY}/${APPNAME}/${l} ${DEPLOY}/${APPNAME}/${i}

mv ${APP_PREFIX}/bin/start${l}.sh ${APP_PREFIX}/bin/start${i}.sh
mv ${APP_PREFIX}/bin/stop${l}.sh ${APP_PREFIX}/bin/stop${i}.sh

/usr/bin/perl -p -i -e "s/${l}/${i}/g" ${APP_PREFIX}/bin/start${i}.sh
/usr/bin/perl -p -i -e "s/${l}/${i}/g" ${APP_PREFIX}/bin/stop${i}.sh  
/usr/bin/perl -p -i -e "s/${l}/${i}/g" ${APP_PREFIX}/${i}/conf/logging.properties
/usr/bin/perl -p -i -e "s/${l}/${i}/g" ${APP_PREFIX}/${i}/conf/server.xml 
/usr/bin/perl -p -i -e "s/${l}/${i}/g" ${APP_PREFIX}/${i}/conf/Catalina/localhost/manager.xml


echo
echo " ====================================="
echo " == Instance Name $APP_PREFIX/========"
echo " ====================================="
/bin/ls -l $APP_PREFIX/ | grep svr_*
echo
echo " ====================================="
echo " === start script $APP_PREFIX/bin ===="
echo " ====================================="
/bin/ls -l $APP_PREFIX/bin/*${i}.sh
echo
echo " ====================================="
echo " === DOCROOT ${DOCROOT}/${APPNAME} ==="
echo " ====================================="
/bin/ls -l ${DOCROOT}/${APPNAME}/ | tail -1
echo
echo " ====================================="
echo " === DEPLOY ${DEPLOY}/${APPNAME} ====="
echo " ====================================="
/bin/ls -l ${DEPLOY}/${APPNAME}/ | tail -1
echo " ====================================="
echo " ====================================="
echo " =  End                              ="
echo " ====================================="

========================================================================
 
 

댓글을 달아 주세요