场景需求

需要判断是否有新内容更新,确定有更新之后执行pull操作,然后pull成功之后再将新内容进行复制到其他地方

#!/bin/bash
pushd /data/git/coding/GoToinstall
git remote show origin | grep 最新
if [[ $? -eq 0 ]];then
        echo "Is Latest"
        exit 0
fi
git remote show origin | grep "up to date"
if [[ $? -eq 0 ]];then
        echo "Is Latest"
        exit 0
fi
git pull
python3 update_to_html.py

效果

[root@bxy1 shell]# ./GoToInstall.sh 
/data/git/coding/GoToinstall /data/auto_upgrade/shell
    master 推送至 master (最新)
Is Latest
[root@bxy1 shell]#