Created
June 27, 2021 16:47
-
-
Save lazyjerry/b46b60b6db0ee03ffd07d68784e621b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 根目錄,作為放置統一 git 上層目錄 | |
F_PATH=放一個路徑; | |
# 行程 ID 檔案路徑 | |
PID_FILE=$F_PATH/deploy.pid; | |
# 檢查行程 ID 檔案是否存在 | |
if [ -f $PID_FILE ]; then | |
# 取得行程 ID | |
PID=$(cat $PID_FILE) | |
# 檢查行程是否有在執行 | |
ps -p $PID > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
echo "This script is already running!" | |
exit 1 | |
fi | |
fi | |
# 行程沒有在執行,將目前行程 ID 寫入檔案 | |
echo $$ > $PID_FILE | |
# 檢查行程 ID 檔案是否成功被建立 | |
if [ $? -ne 0 ]; then | |
echo "Could not create PID file." | |
exit 1 | |
fi | |
# 主要工作 | |
dir=$(ls -l $F_PATH/ |awk '/^d/ {print $NF}') | |
for i in $dir | |
do | |
echo "PULL GIT"; | |
echo $F_PATH/$i; | |
cd $F_PATH/$i; | |
git config core.fileMode false; | |
git pull; | |
done | |
# 刪除鎖定檔案 | |
rm -f ${PID_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment