shell一键启动脚本

#!/bin/sh
export EUREKA=eureka.jar
export ADMINAUTH=admin-auth-0.0.1.jar
export ADMINCONFIG=admin-config-0.0.1.jar
export ADVICE=hospital-advice.jar
export AUTH=hospital-auth.jar
export DATA=hospital-data.jar
export GATEWAY=hospital-gateway.jar
export INFORM=hospital-inform.jar
export INTELLIGENTDIAGNOSIS=hospital-intelligentDiagnosis-1.0.jar
export INTERACTIVE=hospital-interactive-1.0-SNAPSHOT.jar
export MESSAGE=hospital-message-1.0.jar
export NEWS=hospital-news-2.0.4.RELEASE.jar
export ORDER=hospital-order.jar
export SUBSCRIBE=hospital-subscribe-0.0.1-SNAPSHOT.jar
export LOG=hospital-LOG-0.0.1-SNAPSHOT.jar

export WEBPATIENT=hospital-web-patient-1.0.jar
export ONLIONDIAGNOSIS=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export UIDOCTOR=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export CHATROOM=AUTH-server-0.0.1-SNAPSHOT.jar

export EUREKA_port=8761
export ADMINAUTH_port=7053
export ADMINCONFIG_port=7054
export ADVICE_port=7007
export AUTH_port=7050
export DATA_port=7011
export GATEWAY_port=7052
export INFORM_port=7002
export INTELLIGENTDIAGNOSIS_port=7004
export INTERACTIVE_port=7010
export MESSAGE_port=7015
export NEWS_port=7009
export ORDER_port=7012
export SUBSCRIBE_port=7003
export LOG_port=7060

export CHATROOM_port=AUTH-server-0.0.1-SNAPSHOT.jar
export ONLIONDIAGNOSIS_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export WEBPATIENT_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export UIDOCTOR_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 

 
case "$1" in
 
start)
    ## 启动eureka 
    EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
    if [ ! -n "$EUREKA_pid" ]; then
        echo "--------eureka 开始启动--------------"
        nohup java -jar -Xmx512m -Xms512m $EUREKA >/dev/null 2>&1 &
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        until [ -n "$EUREKA_pid" ]
            do
              EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "EUREKA pid is $EUREKA_pid" 
        echo "--------eureka 启动成功--------------"
        fi
 
        ## 启动AUTH
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$AUTH_pid" ]; then
        echo "--------开始启动AUTH---------------"
        nohup java -jar $AUTH >> ./yang/mydata/logs/auth.log 2>&1 &
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$AUTH_pid" ]
            do
              AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "AUTH pid is $AUTH_pid"     
        echo "---------AUTH 启动成功-----------"
        fi

        ## 启动GATEWAY
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$GATEWAY_pid" ]; then
        echo "--------开始启动GATEWAY---------------"
        nohup java -jar $GATEWAY >>./yang/mydata/logs/gateway.log 2>&1 &
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$GATEWAY_pid" ]
            do
              GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "GATEWAY pid is $GATEWAY_pid"     
        echo "---------GATEWAY 启动成功-----------"
        fi

        ## 启动MESSAGE
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$MESSAGE_pid" ]; then
        echo "--------开始启动MESSAGE---------------"
        nohup java -jar -Xmx512m -Xms512m $MESSAGE >>./yang/mydata/logs/message.log 2>&1 &
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$MESSAGE_pid" ]
            do
              MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "MESSAGE pid is $MESSAGE_pid"     
        echo "---------MESSAGE 启动成功-----------"
        fi      

        ## 启动INFORM
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INFORM_pid" ]; then
        echo "--------开始启动INFORM---------------"
        nohup java -jar -Xmx512m -Xms512m $INFORM >>./yang/mydata/logs/inform.log 2>&1 &
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INFORM_pid" ]
            do
              INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INFORM pid is $INFORM_pid"     
        echo "---------INFORM 启动成功-----------"
        fi

        ## 启动LOG
#       LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'`
#       if [ ! -n "$LOG_pid" ]; then
#        echo "--------开始启动LOG---------------"
#        nohup java -jar -Xmx512m -Xms512m $LOG >>./yang/mydata/logs/loglistener.log 2>&1 &
#        LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'` 
#        until [ -n "$LOG_pid" ]
#            do
#              LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'`  
#            done
#        echo "LOG pid is $LOG_pid"     
#        echo "---------LOG 启动成功-----------"
#       fi
        
        
        ## 启动INTELLIGENTDIAGNOSIS
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTELLIGENTDIAGNOSIS_pid" ]; then
        echo "--------开始启动INTELLIGENTDIAGNOSIS---------------"
        nohup java -jar -Xmx512m -Xms512m $INTELLIGENTDIAGNOSIS >/dev/null 2>&1 &
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTELLIGENTDIAGNOSIS_pid" ]
            do
              INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTELLIGENTDIAGNOSIS pid is $INTELLIGENTDIAGNOSIS_pid"     
        echo "---------INTELLIGENTDIAGNOSIS 启动成功-----------"
        fi
        
        
        ## 启动INTERACTIVE
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTERACTIVE_pid" ]; then
        echo "--------开始启动INTERACTIVE---------------"
        nohup java -jar -Xmx512m -Xms512m $INTERACTIVE >>./yang/mydata/logs/interactive.log 2>&1 &
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTERACTIVE_pid" ]
            do
              INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTERACTIVE pid is $INTERACTIVE_pid"     
        echo "---------INTERACTIVE 启动成功-----------"
        fi
            
        ## 启动ORDER
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ORDER_pid" ]; then
        echo "--------开始启动ORDER---------------"
        nohup java -jar -Xmx512m -Xms512m $ORDER >/dev/null 2>&1 &
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ORDER_pid" ]
            do
              ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ORDER pid is $ORDER_pid"     
        echo "---------ORDER 启动成功-----------"
        fi
        
        ## 启动SUBSCRIBE
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$SUBSCRIBE_pid" ]; then
        echo "--------开始启动SUBSCRIBE---------------"
        nohup java -jar -Xmx512m -Xms512m $SUBSCRIBE >/dev/null 2>&1 &
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$SUBSCRIBE_pid" ]
            do
              SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "SUBSCRIBE pid is $SUBSCRIBE_pid"     
        echo "---------SUBSCRIBE 启动成功-----------"
        fi  

        ## 启动ADMINAUTH
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINAUTH_pid" ]; then
        echo "--------开始启动ADMINAUTH---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINAUTH >/dev/null 2>&1 &
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINAUTH_pid" ]
            do
              ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINAUTH pid is $ADMINAUTH_pid"     
        echo "---------ADMINAUTH 启动成功-----------"
        fi
        
        ## 启动ADMINCONFIG
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINCONFIG_pid" ]; then
        echo "--------开始启动ADMINCONFIG---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINCONFIG >/dev/null 2>&1 &
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINCONFIG_pid" ]
            do
              ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINCONFIG pid is $ADMINCONFIG_pid"     
        echo "---------ADMINCONFIG 启动成功-----------"
        fi
        
        
        ## 启动ADVICE
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADVICE_pid" ]; then
        echo "--------开始启动ADVICE---------------"
        nohup java -jar -Xmx512m -Xms512m $ADVICE >/dev/null 2>&1 &
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADVICE_pid" ]
            do
              ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADVICE pid is $ADVICE_pid"     
        echo "---------ADVICE 启动成功-----------"
        fi
                
        ## 启动DATA
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$DATA_pid" ]; then
        echo "--------开始启动DATA---------------"
        nohup java -jar -Xmx512m -Xms512m $DATA >/dev/null 2>&1 &
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$DATA_pid" ]
            do
              DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "DATA pid is $DATA_pid"     
        echo "---------DATA 启动成功-----------"
        fi
        
        ## 启动NEWS
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$NEWS_pid" ]; then
        echo "--------开始启动NEWS---------------"
        nohup java -jar -Xmx512m -Xms512m $NEWS >/dev/null 2>&1 &
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$NEWS_pid" ]
            do
              NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "NEWS pid is $NEWS_pid"     
        echo "---------NEWS 启动成功-----------"
        fi

                
        echo "===startAll success==="
        ;;
 
 stop)
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "EUREKA killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINAUTH killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINCONFIG killed success"
        fi
        
        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "NEWS killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADVICE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "AUTH killed success"
        fi
        
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "DATA killed success"
        fi
        
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY process not exists or stop success"
        else
            kill -9 $P_ID
            echo "GATEWAY killed success"
        fi

        P_ID=`ps -ef | grep -w $LOG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===LOG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "LOG killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INFORM killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTELLIGENTDIAGNOSIS killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTERACTIVE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "MESSAGE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ORDER killed success"
        fi  
        
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "SUBSCRIBE killed success"
        fi      
        
        echo "===stopAll success==="
        ;;  
        
 restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restartAll success==="
        ;;   
        
 notstart)
 
        echo "notstart find bigin:"
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA ==="
        fi
        
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG ==="
        
        fi
        
#       P_ID=`ps -ef | grep -w $LOG | grep -v "grep" | awk '{print $2}'`
#       if [ "$P_ID" == "" ]; then
#           echo "===LOG ==="   
#       fi

        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER ==="
        
        fi  
        
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE ==="
        
            echo "SUBSCRIBE killed success"
        fi      
        
        echo "===findAll success==="
        ;;  

EUREKA|eureka)   
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "EUREKA killed success"
        fi
        ## 启动eureka 
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$EUREKA_pid" ]; then
        echo "--------eureka 开始启动--------------"
        nohup java -jar -Xmx512m -Xms512m $EUREKA >/dev/null 2>&1 &
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        until [ -n "$EUREKA_pid" ]
            do
              EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "EUREKA pid is $EUREKA_pid" 
        echo "--------eureka 启动成功--------------"
        fi
        ;;   

 ADMINAUTH|adminauth)       
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINAUTH killed success"
        fi
        ## 启动ADMINAUTH
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINAUTH_pid" ]; then
        echo "--------开始启动ADMINAUTH---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINAUTH >/dev/null 2>&1 &
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINAUTH_pid" ]
            do
              ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINAUTH pid is $ADMINAUTH_pid"     
        echo "---------ADMINAUTH 启动成功-----------"
        fi      
        ;;   

 ADMINCONFIG|adminconfig)
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINCONFIG killed success"
        fi
        ## 启动ADMINCONFIG
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINCONFIG_pid" ]; then
        echo "--------开始启动ADMINCONFIG---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINCONFIG >/dev/null 2>&1 &
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINCONFIG_pid" ]
            do
              ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINCONFIG pid is $ADMINCONFIG_pid"     
        echo "---------ADMINCONFIG 启动成功-----------"
        fi
        ;;   
        
        
 NEWS|news) 
        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "NEWS killed success"
        fi
        ## 启动NEWS
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$NEWS_pid" ]; then
        echo "--------开始启动NEWS---------------"
        nohup java -jar -Xmx512m -Xms512m $NEWS >/dev/null 2>&1 &
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$NEWS_pid" ]
            do
              NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "NEWS pid is $NEWS_pid"     
        echo "---------NEWS 启动成功-----------"
        fi
        ;;   
        
 ADVICE|advice) 
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADVICE killed success"
        fi
        ## 启动ADVICE
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADVICE_pid" ]; then
        echo "--------开始启动ADVICE---------------"
        nohup java -jar -Xmx512m -Xms512m $ADVICE >/dev/null 2>&1 &
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADVICE_pid" ]
            do
              ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADVICE pid is $ADVICE_pid"     
        echo "---------ADVICE 启动成功-----------"
        fi
        ;;   
        
 AUTH|auth)     
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "AUTH killed success"
        fi
        ## 启动AUTH
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$AUTH_pid" ]; then
        echo "--------开始启动AUTH---------------"
        nohup java -jar $AUTH >> ./yang/mydata/logs/auth.log 2>&1 &
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$AUTH_pid" ]
            do
              AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "AUTH pid is $AUTH_pid"     
        echo "---------AUTH 启动成功-----------"
        fi
        ;;   

 DATA|data)     
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "DATA killed success"
        fi
        ## 启动DATA
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$DATA_pid" ]; then
        echo "--------开始启动DATA---------------"
        nohup java -jar -Xmx512m -Xms512m $DATA >/dev/null 2>&1 &
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$DATA_pid" ]
            do
              DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "DATA pid is $DATA_pid"     
        echo "---------DATA 启动成功-----------"
        fi
        ;;   
        
 GATEWAY|gateway)   
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY process not exists or stop success"
        else
            kill -9 $P_ID
            echo "GATEWAY killed success"
        fi
        ## 启动GATEWAY
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$GATEWAY_pid" ]; then
        echo "--------开始启动GATEWAY---------------"
        nohup java -jar $GATEWAY >>./yang/mydata/logs/gateway.log 2>&1 &
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$GATEWAY_pid" ]
            do
              GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "GATEWAY pid is $GATEWAY_pid"     
        echo "---------GATEWAY 启动成功-----------"
        fi
        ;;   
        
 INFORM|inform)     
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INFORM killed success"
        fi
        ## 启动INFORM
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INFORM_pid" ]; then
        echo "--------开始启动INFORM---------------"
        nohup java -jar -Xmx512m -Xms512m $INFORM >>./yang/mydata/logs/inform.log 2>&1 &
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INFORM_pid" ]
            do
              INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INFORM pid is $INFORM_pid"     
        echo "---------INFORM 启动成功-----------"
        fi
        ;;   
        
 INTELLIGENTDIAGNOSIS|intelligentdiagnosis)     
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTELLIGENTDIAGNOSIS killed success"
        fi
        ## 启动INTELLIGENTDIAGNOSIS
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTELLIGENTDIAGNOSIS_pid" ]; then
        echo "--------开始启动INTELLIGENTDIAGNOSIS---------------"
        nohup java -jar -Xmx512m -Xms512m $INTELLIGENTDIAGNOSIS >/dev/null 2>&1 &
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTELLIGENTDIAGNOSIS_pid" ]
            do
              INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTELLIGENTDIAGNOSIS pid is $INTELLIGENTDIAGNOSIS_pid"     
        echo "---------INTELLIGENTDIAGNOSIS 启动成功-----------"
        fi
        ;;   
        
 INTERACTIVE|interactive)
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTERACTIVE killed success"
        fi
        ## 启动INTERACTIVE
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTERACTIVE_pid" ]; then
        echo "--------开始启动INTERACTIVE---------------"
        nohup java -jar -Xmx512m -Xms512m $INTERACTIVE >>./yang/mydata/logs/interactive.log 2>&1 &
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTERACTIVE_pid" ]
            do
              INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTERACTIVE pid is $INTERACTIVE_pid"     
        echo "---------INTERACTIVE 启动成功-----------"
        fi
        ;;   
        
 MESSAGE|message)
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "MESSAGE killed success"
        fi
        ## 启动MESSAGE
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$MESSAGE_pid" ]; then
        echo "--------开始启动MESSAGE---------------"
        nohup java -jar -Xmx512m -Xms512m $MESSAGE >>./yang/mydata/logs/message.log 2>&1 &
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$MESSAGE_pid" ]
            do
              MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "MESSAGE pid is $MESSAGE_pid"     
        echo "---------MESSAGE 启动成功-----------"
        fi
        ;;   
        
 ORDER|order)       
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ORDER killed success"
        fi  
        ## 启动ORDER
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ORDER_pid" ]; then
        echo "--------开始启动ORDER---------------"
        nohup java -jar -Xmx512m -Xms512m $ORDER >/dev/null 2>&1 &
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ORDER_pid" ]
            do
              ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ORDER pid is $ORDER_pid"     
        echo "---------ORDER 启动成功-----------"
        fi
        ;;   
        
 SUBSCRIBE|subscribe) 
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "SUBSCRIBE killed success"
        fi      
        ## 启动SUBSCRIBE
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$SUBSCRIBE_pid" ]; then
        echo "--------开始启动SUBSCRIBE---------------"
        nohup java -jar -Xmx512m -Xms512m $SUBSCRIBE >/dev/null 2>&1 &
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$SUBSCRIBE_pid" ]
            do
              SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "SUBSCRIBE pid is $SUBSCRIBE_pid"     
        echo "---------SUBSCRIBE 启动成功-----------"
        fi  
        ;;  
        
esac    
exit 0

你可能感兴趣的:(shell一键启动脚本)