simplified and reduced output and notification data
This commit is contained in:
		| @@ -2,40 +2,33 @@ | |||||||
|  |  | ||||||
| # Function to process each repo-destination pair | # Function to process each repo-destination pair | ||||||
| process_repo() { | process_repo() { | ||||||
|     REPO_URL=$1 |     FULL_REPO_URL=$1 | ||||||
|     DESTINATION=$2 |     DESTINATION=$2 | ||||||
|  |  | ||||||
|     # Set Git credentials |     # Extract the URL without credentials for logging and notifications | ||||||
|     git config --global credential.helper 'store --file /tmp/git-credentials' |     CLEAN_REPO_URL=$(echo "$FULL_REPO_URL" | sed 's/https:\/\/[^@]*@/https:\/\//') | ||||||
|     echo "url=$REPO_URL" > /tmp/git-credentials |  | ||||||
|     echo "username=$GIT_USERNAME" >> /tmp/git-credentials |  | ||||||
|     echo "password=$GIT_PASSWORD" >> /tmp/git-credentials |  | ||||||
|  |  | ||||||
|     # Directory to hold the repository locally |     # Directory to hold the repository locally | ||||||
|     REPO_DIR="/root/Repo_Cache/$(basename $REPO_URL)" |     REPO_DIR="/root/Repo_Cache/$(basename $CLEAN_REPO_URL .git)" | ||||||
|  |  | ||||||
|     # Clone the repo if it doesn't exist, or navigate to it if it does |     # Clone the repo if it doesn't exist, or navigate to it if it does | ||||||
|     if [ ! -d "$REPO_DIR" ]; then |     if [ ! -d "$REPO_DIR" ]; then | ||||||
|         curl -d "Cloning: $REPO_URL" $NTFY_URL |         curl -d "Cloning: $CLEAN_REPO_URL" $NTFY_URL | ||||||
|         echo "Cloning: $REPO_URL" |         git clone "$FULL_REPO_URL" "$REPO_DIR" > /dev/null 2>&1 | ||||||
|         git clone "$REPO_URL" "$REPO_DIR" |  | ||||||
|     fi |     fi | ||||||
|     cd "$REPO_DIR" |     cd "$REPO_DIR" || exit | ||||||
|  |  | ||||||
|     # Fetch the latest changes |     # Fetch the latest changes | ||||||
|     git fetch origin main |     git fetch origin main > /dev/null 2>&1 | ||||||
|  |  | ||||||
|     # Check if the local repository is behind the remote |     # Check if the local repository is behind the remote | ||||||
|     LOCAL=$(git rev-parse @) |     LOCAL=$(git rev-parse @) | ||||||
|     REMOTE=$(git rev-parse @{u}) |     REMOTE=$(git rev-parse @{u}) | ||||||
|  |  | ||||||
|     if [ $LOCAL != $REMOTE ]; then |     if [ "$LOCAL" != "$REMOTE" ]; then | ||||||
|         curl -d "Updating: $REPO_URL" $NTFY_URL |         curl -d "Updating: $CLEAN_REPO_URL" $NTFY_URL | ||||||
|         echo "Updating: $REPO_URL" |         git pull origin main > /dev/null 2>&1 | ||||||
|         git pull origin main |         rsync -av --delete --exclude '.git/' ./ "$DESTINATION" > /dev/null 2>&1 | ||||||
|         rsync -av --delete --exclude '.git/' ./ "$DESTINATION" |  | ||||||
|     else |  | ||||||
|         echo "Repository $REPO_URL Up-to-Date" |  | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -57,4 +50,3 @@ while true; do | |||||||
|     # Wait for 5 seconds before the next iteration |     # Wait for 5 seconds before the next iteration | ||||||
|     sleep 5 |     sleep 5 | ||||||
| done | done | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user