#!/bash/sh TARGET_MODULE="" if [ "$1" == "appservice" ] then TARGET_MODULE="xchat-web-api" elif [ "$1" == "record" ] then TARGET_MODULE="xchat-web-record" elif [ "$1" == "task" ] then TARGET_MODULE="xchat-web-task" fi TARGET_USER="root" TARGET_IP="120.79.211.173" TARGET_FROM_BASE="/home/chensenlai/shanp/project/chat-server/apiservice/" TARGET_FROM="${TARGET_MODULE}/target/$1.jar" TARGET_TO_BASE="/srv/server/chat-server/$1/" TARGET_TO="$1.jar" TARGET_TO_SWAP="${TARGET_TO}.swap" if [ -z TARGET_MODULE ] then echo -e "\033[35merror: unkonw target. [appservice|record|task]\033[0m" exit -1 fi echo "cd into ${TARGET_FROM_BASE}${TARGET_FROM}" cd ${TARGET_FROM_BASE} #echo -e "\033[35m 0) switch branch ... \033[0m" #git checkout dev #echo -e "\033[35m 1) git pull ... \033[0m" #git pull echo " 2) build project $1..." mvn clean mvn install -Ptest -pl ${TARGET_MODULE} -am echo " 3) scp to ${TARGET_USER}@${TARGET_IP}:${TARGET_TO_BASE}${TARGET_TO_SWAP}" scp ${TARGET_FROM_BASE}${TARGET_FROM} ${TARGET_USER}@${TARGET_IP}:${TARGET_TO_BASE}${TARGET_TO_SWAP} echo " 4) ${TARGET_USER}@${TARGET_IP} ${TARGET_TO_BASE}run.sh restart..." ssh -l ${TARGET_USER} ${TARGET_IP} "cd ${TARGET_TO_BASE}; mv ${TARGET_TO_SWAP} ${TARGET_TO}; sh run.sh restart" echo done! exit 0