diff --git a/.env b/.env index 29ca32a..b4b2d57 100644 --- a/.env +++ b/.env @@ -6,6 +6,5 @@ GIT_PASSWORD=USE-AN-APP-PASSWORD NTFY_URL=https://ntfy.cyberstrawberry.net/git-repo-updater # Repository/Destination Pairs (Add as Many as Needed) -REPO_01="https://git.bunny-lab.io/repo1.git,/srv/containers/destination" -REPO_02="https://git.bunny-lab.io/repo1.git,/srv/containers/destination" -REPO_03="https://git.bunny-lab.io/repo1.git,/srv/containers/destination" \ No newline at end of file +REPO_01="https://${GIT_USERNAME}:${GIT_PASSWORD}@git.bunny-lab.io/bunny-lab/docs.git,/srv/containers/material-mkdocs/docs/docs" +REPO_02="https://${GIT_USERNAME}:${GIT_PASSWORD}@git.bunny-lab.io/GitOps/servers.bunny-lab.io.git,/srv/containers/homepage-docker" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ef0c593..7958d49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY repo_watcher.sh /repo_watcher.sh RUN chmod +x /repo_watcher.sh #Create Directory to store Repositories -RUN mkdir -p /root/Repo_Watcher +RUN mkdir -p /root/Repo_Cache # Start script (Alpine uses /bin/sh instead of /bin/bash) CMD ["/bin/sh", "-c", "/repo_watcher.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a4bc0d4..45662bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,5 @@ services: image: git.bunny-lab.io/container-registry/git-repo-updater:latest volumes: - /srv/containers:/srv/containers + - /srv/containers/git-repo-updater/Repo_Cache:/root/Repo_Cache restart: always \ No newline at end of file diff --git a/repo_watcher.sh b/repo_watcher.sh index 567db68..b111a69 100644 --- a/repo_watcher.sh +++ b/repo_watcher.sh @@ -12,7 +12,7 @@ process_repo() { echo "password=$GIT_PASSWORD" >> /tmp/git-credentials # Directory to hold the repository locally - REPO_DIR="/root/Repo_Watcher/$(basename $REPO_URL)" + REPO_DIR="/root/Repo_Cache/$(basename $REPO_URL)" # Clone the repo if it doesn't exist, or navigate to it if it does if [ ! -d "$REPO_DIR" ]; then @@ -43,10 +43,18 @@ process_repo() { while true; do # Iterate over each environment variable matching 'REPO_[0-9]+' env | grep '^REPO_[0-9]\+=' | while IFS='=' read -r name value; do - IFS=',' read -ra REPO_DEST <<< "$value" - process_repo "${REPO_DEST[0]}" "${REPO_DEST[1]}" + # Split the value by comma and read into separate variables + OLD_IFS="$IFS" # Save the original IFS + IFS=',' # Set IFS to comma for splitting + set -- $value # Set positional parameters ($1, $2, ...) + REPO_URL="$1" # Assign first parameter to REPO_URL + DESTINATION="$2" # Assign second parameter to DESTINATION + IFS="$OLD_IFS" # Restore original IFS + + process_repo "$REPO_URL" "$DESTINATION" done # Wait for 5 seconds before the next iteration sleep 5 done +