一個腳本從git上pull 並更新到服務器
阿新 • • 發佈:2017-10-17
一個 res then data date -c print error err
#/bin/bash cd /src/pid01-beta/ echo "update pid01.." git pull if [ $? -ne 0 ]; then echo "update pid01(clientErrorCode.json) from git failed" exit 1 fi res=`git pull|grep -c "up-to-date"` if [ $res -eq 1 ]; then echo "pid01 already latest,quit update" exit 1 fi go buildif [ $? -ne 0 ]; then echo "go build failed" exit 1 fi rm -rf /data/wesite/pid01-beta if [ $? -ne 0 ]; then echo "delete old pid01 file failed" exit 1 fi mv /src/pid01-beta/pid01-beta /data/website/ if [ $? -ne 0 ]; then echo "move new pid01 file failed" exit 1 fipidno=`ps aux|grep pid01|grep -v "grep"|awk ‘{print $2}‘` kill -9 $pidno if [ $? -ne 0 ]; then echo "old pid01 kill failed" exit 1 fi sleep 5 pid01pid=`ps aux|grep pid01|grep -v "grep"|awk ‘{print $2}‘` if [ "$pid01pid" ];then echo "new version pid01 is running now" fi
一個腳本從git上pull 並更新到服務器