寫的簡單sh腳本1

#!/bin/bash
export LANG="en_US.UTF-8"
#chmod +x filename 記得給文件加可執行權限
echo "start!!!"

vsim=/home/vsim-core/cloudwise
 #204 agent
 # JavaAgent_2.4.1_amc   JavaAgent_2.4.1_cfgs  JavaAgent_2.4.1_dse   JavaAgent_2.4.1_mno-provider  JavaAgent_2.4.1_sc        JavaAgent_2.4.1_vsim-web
 # JavaAgent_2.4.1_apdu  JavaAgent_2.4.1_dms   JavaAgent_2.4.1_ebiz  JavaAgent_2.4.1_msgq          JavaAgent_2.4.1_srms-web  JavaAgent_2.4.1.zip
 # JavaAgent_2.4.1_access  JavaAgent_2.4.1_cdr   JavaAgent_2.4.1_dre   JavaAgent_2.4.1_lps   JavaAgent_2.4.1_rss           JavaAgent_2.4.1_tls
 
 #207 agent
 #JavaAgent_2.4.1_res      JavaAgent_2.4.1_srms-provider  JavaAgent_2.4.1_user JavaAgent_2.4.1_assets
 #JavaAgent_2.4.1_uqb-agent      JavaAgent_2.4.1_vsim-product JavaAgent_2.4.1_sqb JavaAgent_2.4.1_uqb-node             
#須要替換的jar
activemq=cloudwise-javacode-plugin-activemq.jar
mina=cloudwise-javacode-plugin-mina.jar
redis=cloudwise-javacode-plugin-redis.jar
kafka=cloudwise-javacode-plugin-kafka.jar
agent=agent.jar
plugins="${activemq} ${mina} ${redis} ${kafka}"

#須要替換那些文件下的jar
files="access amc cfgs apdu cdr dse dms dre mno-provider ebiz lps sc msgq rss vsim-web srms-web tls res uqb-agent srms-provider user assets vsim-product sqb uqb-node"

agentCp(){

for skill in ${files}; do

if [ -d ${vsim}/JavaAgent_2.4.1_${skill} ]
then
   echo "有${vsim}/JavaAgent_2.4.1_${skill}文件目錄"
    if [ -e ${vsim}/$agent ]; then
        echo "有${vsim}/${agent}文件,放入${vsim}/JavaAgent_2.4.1_${skill}/lib文件中"
        rm -rf  ${vsim}/JavaAgent_2.4.1_${skill}/lib/${agent};
        echo "刪除${vsim}/JavaAgent_2.4.1_${skill}/lib/${agent}"
        cp ${vsim}/${agent} ${vsim}/JavaAgent_2.4.1_${skill}/lib
        echo "複製${vsim}/${agent}到${vsim}/JavaAgent_2.4.1_${skill}/lib文件"
    else
        echo "沒有${vsim}/${agent}文件"
    fi

        for jar in ${plugins}; do
        if [ -e ${vsim}/$jar ]; then
            echo "有${vsim}/${jar}文件,放入${vsim}/JavaAgent_2.4.1_${skill}/plugins文件中"
            rm -rf  ${vsim}/JavaAgent_2.4.1_${skill}/plugins/${jar};
            echo "刪除${vsim}/JavaAgent_2.4.1_${skill}/plugins/${jar}"
            cp ${vsim}/${jar} ${vsim}/JavaAgent_2.4.1_${skill}/plugins
            echo "複製${vsim}/${jar}到${vsim}/JavaAgent_2.4.1_${skill}/plugins文件"
        else
            echo "沒有${vsim}/${jar}文件"
        fi
        done

    else
    echo "沒有${vsim}/JavaAgent_2.4.1_${skill}文件目錄"
    fi

done
}
#替換agent的jar包
agentCp

#忽略-----------------------------------------------------------------------------------------
PID=0
APP_JAR=okhttp8081.jar
filename=/Users/heliming/IdeaProjects/democloud/okhttp/target
getPID(){
    javaps=`jps -l | grep $APP_MAIN`
    if [ -n "$javaps" ]; then
        for javap in $javaps ;do
        PID=`echo $javap`
        echo "$PID"
        break;
        done
    else
        PID=0
    fi
}

startup(){
    getPID
    echo "================================================================================================================"
    if [ $PID -ne 0 ]; then
        echo "$APP_JAR already started(PID=$PID)"
        echo "================================================================================================================"
    else
        
        nohup java -jar $filename/$APP_JAR &

        sleep 3
        getPID
        if [ $PID -ne 0 ]; then
            echo "(PID=$PID)[Success]"
            echo "================================================================================================================"
        else
            echo "[Failed]"
            echo "================================================================================================================"
        fi
    fi
}

#啓動jar包
#startup




#啓動vsim項目
#vsims="項目"
  # for vsim in ${vsims}; do
 
   # echo "shutdown vsim"

  #  echo "start vism"
#done
相關文章
相關標籤/搜索