一个脚本从git上pull 并更新到服务器

#/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 build

if [ $? -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
fi


pidno=`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

 

posted @ 2017-10-17 09:45  Oops!#  阅读(2048)  评论(0编辑  收藏  举报