#!/bin/bash DIR=/www/wwwroot/ DATA=$(ls -l "$DIR" | awk '{print$9}') for i in $DATA do CUR_DIR="$DIR$i" # 排除错误项目,如果当前路径字符串包含runtime则跳出 if [[ "$CUR_DIR" == *"runtime"* ]]; then continue fi # URL="https://$i/index/index/checkout?pwd=925" # echo $URL # curl $URL cd $CUR_DIR # 排除正常拉取项目 PULL=$(git pull) if [[ "$PULL" == "Already up-to-date." ]]; then echo "$CUR_DIR---->$PULL" continue fi # echo "开始执行强制拉取" GIT_INDEX_LOCK="$CUR_DIR/.git/index" rm -rf $GIT_INDEX_LOCK GIT_INDEX_LOCK="$CUR_DIR/.git/index.lock" rm -rf $GIT_INDEX_LOCK # git checkout -f git reset --hard origin/master git pull 2>&1 ls -all -I "runtime" -I ".user.ini" -I "public/.user.ini" -I "." -I ".." -I " " | awk '{print$9}' | awk 'NF > 0' | xargs -0 -d "\n" chown -R www:www ENV="$CUR_DIR/.example" TARGET="$CUR_DIR/.env" # 排除其他外网服务器 # IP=$(ifconfig | grep 218.2.0 | awk '{print$2}') # echo $IP # if [[ "$IP" == *"218.2.0"* ]]; then # if [ -f "$ENV" ]; then # mv $ENV $TARGET # echo "move file .example to .env success" # fi # fi echo "==================================" done