206主要开发脚本内容

#alias rm="sh /usr/local/.rmove.sh"
. /usr/local/.traces.sh
[tomcat@app01 ~]$ more /usr/local/.rmove.sh
#!/bin/sh
PARA_CNT=$#
TRASH_DIR="/data01/.trash"
root_dir=`ls -trl / |grep ^d|awk '{print "/"$9"/"}'`

for i in $*; do
    if [ `echo $root_dir |grep '$i' |wc -l` -gt 0 ]
    then
        echo "operation not permit"
        exit
    fi
    if [ $i == "-rf" -o $i == "-r" -o $i == "-f" ]
    then :
    elif [ `echo $i |grep del-|wc -l` -gt 0 ]
        then
                rm -rf ${i#*del-}    
    else 
        STAMP=`date +%Y%m%d-%H%M%S-%s`
        fileName=`basename $i`
        mv $i $TRASH_DIR/$fileName.$STAMP
   fi
done

访问跟踪

 

[tomcat@app01 ~]$ more /usr/local/.traces.sh
#!/bin/sh
#history
export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S]"
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
HISTDIR=/tmp/.operation
if [ -z $USER_IP  ]
then
  USER_IP=`hostname`
fi
if [ ! -d $HISTDIR ]
then
   mkdir -p $HISTDIR
   chmod 777 $HISTDIR
fi
if [ ! -d $HISTDIR/${LOGNAME} ]
then
    mkdir -p $HISTDIR/${LOGNAME}
    chmod 300 $HISTDIR/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date +%Y%m%d_%H%M%S`
histfile="$HISTDIR/${LOGNAME}/${USER_IP}.hist.$DT"
if [ ! -f $histfile ]
then
touch $histfile
fi
export HISTSIZE=4096
DT=`date +%Y%m%d_%H%M%S`
export HISTFILE="$HISTDIR/${LOGNAME}/${USER_IP}.hist.$DT"
chmod 600 $HISTDIR/${LOGNAME}/*.hist* 2>/dev/null

tomcat 部署文档

total 32
-rw-rw-r-- 1 tomcat tomcat   11 May 12  2016 delOldVersionWar.sh
-rwxrw-r-- 1 tomcat tomcat 3969 Jan 28  2016 publish.sh
-rw-rw-r-- 1 tomcat tomcat  736 Mar 21  2016 startTomcatAll.sh
-rw-rw-r-- 1 tomcat tomcat  306 Mar 21  2016 stopTomcatAll.sh
-rwxrw-r-- 1 tomcat tomcat 5423 May 31  2016 updateConf.sh
-rw-rw-r-- 1 tomcat tomcat  483 Apr 11  2016 utomcat.conf
-rw-rw-r-- 1 tomcat tomcat  282 Dec 30  2015 webserviceAddressConfig.xml
[tomcat@app01 shPath]$ more delOldVersionWar.sh 
#!/bin/sh

[tomcat@app01 shPath]$ more publish.sh 
#!/bin/sh
sh ~/.bash_profile
_conf_dir="/home/tomcat/utomcat.conf"
dates=`date +%Y%m%d-%H%m%S-%s`
userage(){
 echo "**************************************************"
 cat $_conf_dir
 echo " As mentioned above,The details that  each tomcat contains the war"
 echo " if you want to release the *.war "
 echo " for 2 instances : "
 echo " release cms.war : ./publish.sh 1"
 echo " release adms.war : ./publish.sh 3" 
 echo "**************************************************"
}
#******1-stop*****
stop(){
 if [ `ls $1 |wc -l` -gt 0  ] 
 then
        echo " "
        echo " "
        echo "**********begin stop ${1} now ,please wait!********************"
        echo "......" 
        sh ${1}/bin/shutdown.sh
        sleep 3
        if [ `ps -ef|grep java|grep ${1}|grep -v grep|wc -l` -gt "0" ]
        then
            _pid=`ps -ef|grep java|grep ${1}|grep -v grep|awk '{print $2}'`
            kill -9 ${_pid}
            if [ ${_pid} != "" ]
                then
                        echo "***********${1} stop successfull**************************"
                fi
        else
           echo "***********${1} stop successfull**************************"
        fi 
  else
       echo "[ERROR] : can't find the path, please check input parameter"
#       exit
 fi
        }

#*******2-del*****
del(){
 
        echo " "
        echo " "
 echo "*************beign del $2/webapps/$1,please wait!*****************"
 echo "......"
 #rm -rf $2/webapps/${1}* 
 if [ `ls $2/webapps/$1 |wc -l` -gt 0 ]
 then
        cp $2/webapps/${1}.war /data01/war/${1}.war_$dates
        /usr/local/.rmove.sh -rf $2/webapps/${1}*
        if [ `ls $2/webapps|grep ${1}* |wc -l` == 0 ]
        then
                echo "************del $2/webapps/$1 sucessfull*******************"
        else
                echo "************[ERROR] : del $2/webapps/$1 ,please check******************"
                exit
        fi
 else
        echo "****************$2/webapps/$1 just not exist **************************" 
 fi
}

#*******3-update****
update(){

        echo " "
        echo " "
echo "************update ${1} now**************"
mv /home/tomcat/${1}.war $2/webapps/
if [ $? == "0" ]
then
        sleep 5;
        if [ `ls -trl $2/webapps|grep ^d|grep $1|wc -l` -lt 1 ]
        then
                unzip $2/webapps/${1}.war -d $2/webapps/${1}
                if [ `ls ${2}/webapps/ |grep ${1} |wc -l` -gt 1 ]
                then 
                        echo "************update $1 success ***************"
                else
                        echo "************[ERROR] : update $1 fail,please check ***************"
                        exit
                fi
        else
                echo "***********please check the war which was uploaded in /home/tomcat*********"
                exit
        fi
fi
        echo " "
        echo " "
echo "************update profiles of $1 now***********"
 sh /home/tomcat/updateConf.sh $1 $2
}


        echo " "
        echo " "
#*******4-start*****
start(){
if [ `ls $1 |wc -l` -gt 0 ]
 then
        echo "**********begin start ${1} now ,please wait!********************"
        echo "......"
        sh ${1}/bin/startup.sh
        sleep 2
        if [ `ps -ef|grep java|grep ${1}|grep -v grep|wc -l` -gt 0 ]
        then
               echo "***********${1} start successfull**************************"
               ps -ef|grep java|grep $1 

        fi
 else
       echo "[ERROR] :can't find the path of tomcat, please check input parameter"
       exit
 fi    
}

#*******It start to work*****
if [ $# -lt 1 -o "$1"_ == "--help"_ ]
then
 userage
        echo '***[ERROR]:please use "./publich.sh --help" to see how to use'
        exit
else
 if [ `grep $1 $_conf_dir |wc -l ` -lt 1 ]
 then
        echo "[ERROR] :can't find the path, please check whether the input parameter is in $_conf_dir"
        userage
        exit
 else
        _warName=`grep $1 ${_conf_dir}|awk '{print $2}'`
        _tomcat=`grep $1 ${_conf_dir}|awk '{print $3}'`
        echo "You will stop the $_tomcat, del $_warName , update ${_warName}'s profile , last ,start the ${_tomcat}"
        if [ `ls -trl|grep $_warName |wc -l` -gt 0 ]
        then
                stop $_tomcat 
                del $_warName $_tomcat
                update $_warName $_tomcat
                start $_tomcat
        else
                echo "You should upload the $_warName to directory(/home/tomcat/) first"
                exit
        fi
 fi
fi 
[tomcat@app01 shPath]$ more startTomcatAll.sh 
#!/bin/sh
#stop cmsTomcat
/home/tomcat/cms_tomcat/bin/startup.sh
cpid=`ps -ef|grep java|grep cms|grep -v grep|awk '{print $2}'|wc -l`
if [ $cpid -gt 0 ]
then
 echo "      cms_tomcat start succesfull"
fi

echo "
        -----------------------------------------------

     "

#stop admsTomcat
/home/tomcat/adms_tomcat/bin/startup.sh
apid=`ps -ef|grep java|grep adms|grep -v grep|awk '{print $2}'`
if [ $apid -gt 0 ]
then
 echo "      adms_tomcat start successful"
fi

echo "
       ------------------------------------------------
 
     "
#stop atuoTomcat
/home/tomcat/auto_tomcat/bin/startup.sh
autopid=`ps -ef|grep java|grep auto|grep -v grep|awk 'print $2}'`
if [ $autopid -gt 0 ]
then
 echo "      auto_tomcat start succesfull"
fi
[tomcat@app01 shPath]$ more stopTomcatAll.sh 
#!/bin/sh
#stop cmsTomcat
cpid=`ps -ef|grep java|grep cms|grep -v grep|awk '{print $2}'`

kill -9 $cpid


#stop admsTomcat

apid=`ps -ef|grep java|grep adms|grep -v grep|awk '{print $2}'`

kill -9 $apid

#stop atuoTomcat

autopid=`ps -ef|grep java|grep auto|grep -v grep|awk 'print $2}'`

kill -9 $autopid
[tomcat@app01 shPath]$ more updateConf.sh 
#!/bin/sh

data_ip="10.118.242.207"

# "***************************FUNCTION**********************************"
cms(){
        sed -i s/"244.164"/"242.207"/g /home/tomcat/cms_tomcat/webapps/cms/WEB-INF/classes/properties/jdbc.properties
        sed -i s/"password=td"/"password=cmstddeploy"/g /home/tomcat/cms_tomcat/webapps/cms/WEB-INF/classes/properties/jdbc.properties
        if [ `grep ${data_ip} /home/tomcat/cms_tomcat/webapps/cms/WEB-INF/classes/properties/*|wc -l` -gt 0 ]
         then
                echo "configuration of cms update successfull"
         else
                echo "update cms fail ,please check which wrong"
         fi
}
deploy(){
         sed -i s/"244.164"/"242.207"/g  /home/tomcat/cms_tomcat/webapps/AutoDeploy/WEB-INF/classes/properties/jdbc.properties
         sed -i s/"password=td"/"password=cmstddeploy"/g  /home/tomcat/cms_tomcat/webapps/AutoDeploy/WEB-INF/classes/properties/jdbc.properties
         if [ `grep ${data_ip} /home/tomcat/cms_tomcat/webapps/AutoDeploy/WEB-INF/classes/properties/*|wc -l` -gt 0 ]
         then
                echo "configuration of deploy update successfull"
         else 
                echo "update deploy fail ,please check which wrong" 
         fi
 } 
interface() {
         sed -i s/"243.129"/"242.207"/g /home/tomcat/auto_tomcat/webapps/InterfaceDemo/configure.xml
         sed -i 5s/'value="at"'/'value="sfatoracle"'/ /home/tomcat/auto_tomcat/webapps/InterfaceDemo/configure.xml

         if [ `grep ${data_ip} /home/tomcat/auto_tomcat/webapps/InterfaceDemo/configure.xml|wc -l` -gt 0 ]
         then
                echo "configuration of InterfaceDemo update successfull"
         else
                echo "update adms fail ,please check which wrong"
         fi
}

adms() {
         sed -i s/"244.164"/"242.207"/g /home/tomcat/adms_tomcat/webapps/Adms/WEB-INF/classes/properties/jdbc.properties
         sed -i s/"username=td"/"username=adms"/g /home/tomcat/adms_tomcat/webapps/Adms/WEB-INF/classes/properties/jdbc.properties 
         sed -i s/"password=td"/"password=sfadmsoracle"/g /home/tomcat/adms_tomcat/webapps/Adms/WEB-INF/classes/properties/jdbc.properties 
         if [ `grep ${data_ip} /home/tomcat/adms_tomcat/webapps/Adms/WEB-INF/classes/properties/*|wc -l` -gt 0 ]
         then
                echo "configuration of adms update successfull"
         else
                echo "update adms fail ,please check which wrong"
         fi
}
pms() {
         rm -rf /home/tomcat/auto_tomcat/webapps/pms/WEB-INF/classes/config/config.txt
         cp /home/tomcat/conf/pms/* /home/tomcat/auto_tomcat/webapps/pms/WEB-INF/classes/config/
         if [ `grep ${data_ip} /home/tomcat/auto_tomcat/webapps/pms/WEB-INF/classes/config/config.txt|wc -l` -gt 0 ]
         then
                echo "configuration of pms update successfull"
         else
                echo "update pms fail ,please check which wrong"
         fi
}
bms(){
        sed -i s/"244.164"/"242.207"/g /home/tomcat/cms_tomcat/webapps/bms/WEB-INF/classes/properties/jdbc.properties
        sed -i s/"password=td"/"password=cmstddeploy"/g /home/tomcat/cms_tomcat/webapps/bms/WEB-INF/classes/properties/jdbc.properties  
        if [ `grep ${data_ip} /home/tomcat/cms_tomcat/webapps/bms/WEB-INF/classes/properties/*|wc -l` -gt 0 ]
         then
                echo "configuration of cms update successfull"
         else
                echo "update cms fail ,please check which wrong"
         fi
}
langyabang() {
         sed -i s/"244.195"/"242.207"/g /home/tomcat/auto_tomcat/webapps/langyabang/WEB-INF/classes/properties/jdbc.properties 
         sed -i s/"password=lyb"/"password=sflyboracle"/g /home/tomcat/auto_tomcat/webapps/langyabang/WEB-INF/classes/properties/jdbc.properties
        # sed -i s/"D:"/' $2/$1'/g $2/webapps/$1/WEB-INF/classes/properties/log4j.properties
         if [ `grep ${data_ip} /home/tomcat/auto_tomcat/webapps/langyabang/WEB-INF/classes/properties/jdbc.properties|wc -l` -gt 0 ]
         then
                echo "configuration of langyabang update successfull"
         else
                echo "update langyabang fail ,please check which wrong"
         fi
}
ems(){
        sed -i s/"244.164"/"242.207"/g /home/tomcat/cms_tomcat/webapps/ems/WEB-INF/classes/properties/jdbc.properties
        sed -i s/"password=td"/"password=cmstddeploy"/g /home/tomcat/cms_tomcat/webapps/ems/WEB-INF/classes/properties/jdbc.properties
        if [ `grep ${data_ip} /home/tomcat/cms_tomcat/webapps/bms/WEB-INF/classes/properties/*|wc -l` -gt 0 ]
         then
                echo "configuration of cms update successfull"
         else
                echo "update cms fail ,please check which wrong"
         fi
}
# "****************************START*********************************" 
if(($# == 0))
then
 echo "*************************************************************"
 echo "useage: ./updateConf.sh number"
 echo "number=1,only update configuration of cms
       number=2,update configuration about cms and autoDeploy
       number=3,update configuration about InterfaceDemo"
 echo "*************************************************************"
else
        case $1 in
                cms) cms ;;
                AutoDeploy) deploy ;;
                bms) bms;;
                InterfaceDemo) interface ;;
                Adms) adms ;;
                ems) ems ;;
                pms) pms ;;
                cmsall) cms
                   deploy 
                   bms;;
                langyabang) langyabang $1 $2 ;;
        esac
fi
[tomcat@app01 shPath]$ more utomcat.conf 
#No      war_name                  tomcat_name
1        cms                       /home/tomcat/cms_tomcat
2        AutoDeploy                /home/tomcat/cms_tomcat
3        bms                       /home/tomcat/cms_tomcat
4        Adms                      /home/tomcat/adms_tomcat
5        pms                       /home/tomcat/auto_tomcat
6        InterfaceDemo             /home/tomcat/auto_tomcat
7        langyabang                /home/tomcat/auto_tomcat
8        ems                       /home/tomcat/cms_tomcat
[tomcat@app01 shPath]$ more webserviceAddressConfig.xml 
<?xml version="1.0" encoding="UTF-8"?>
<wsaddresses>
        <wsaddress syscode="1" address="http://10.118.242.206:8082/Adms/webservice/admsWebservice"></wsaddress>
        <wsaddress syscode="2" address="http://10.118.242.206:8080/cms/webservice/foreignService"></wsaddress>
</wsaddresses>
[tomcat@app01 shPath]$ more delOldVersionWar.sh 
#!/bin/sh

[tomcat@app01 shPath]$ 

 

posted on 2017-05-15 11:12  anruy  阅读(154)  评论(0编辑  收藏  举报

导航