Fixed scripting issues and multi-repo issues.
This commit is contained in:
parent
5415f58c33
commit
ec6bd5f9d2
5
.env
5
.env
@ -6,6 +6,5 @@ GIT_PASSWORD=USE-AN-APP-PASSWORD
|
|||||||
NTFY_URL=https://ntfy.cyberstrawberry.net/git-repo-updater
|
NTFY_URL=https://ntfy.cyberstrawberry.net/git-repo-updater
|
||||||
|
|
||||||
# Repository/Destination Pairs (Add as Many as Needed)
|
# Repository/Destination Pairs (Add as Many as Needed)
|
||||||
REPO_01="https://git.bunny-lab.io/repo1.git,/srv/containers/destination"
|
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.bunny-lab.io/repo1.git,/srv/containers/destination"
|
REPO_02="https://${GIT_USERNAME}:${GIT_PASSWORD}@git.bunny-lab.io/GitOps/servers.bunny-lab.io.git,/srv/containers/homepage-docker"
|
||||||
REPO_03="https://git.bunny-lab.io/repo1.git,/srv/containers/destination"
|
|
@ -9,7 +9,7 @@ COPY repo_watcher.sh /repo_watcher.sh
|
|||||||
RUN chmod +x /repo_watcher.sh
|
RUN chmod +x /repo_watcher.sh
|
||||||
|
|
||||||
#Create Directory to store Repositories
|
#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)
|
# Start script (Alpine uses /bin/sh instead of /bin/bash)
|
||||||
CMD ["/bin/sh", "-c", "/repo_watcher.sh"]
|
CMD ["/bin/sh", "-c", "/repo_watcher.sh"]
|
@ -8,4 +8,5 @@ services:
|
|||||||
image: git.bunny-lab.io/container-registry/git-repo-updater:latest
|
image: git.bunny-lab.io/container-registry/git-repo-updater:latest
|
||||||
volumes:
|
volumes:
|
||||||
- /srv/containers:/srv/containers
|
- /srv/containers:/srv/containers
|
||||||
|
- /srv/containers/git-repo-updater/Repo_Cache:/root/Repo_Cache
|
||||||
restart: always
|
restart: always
|
@ -12,7 +12,7 @@ process_repo() {
|
|||||||
echo "password=$GIT_PASSWORD" >> /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_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
|
# 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
|
||||||
@ -43,10 +43,18 @@ process_repo() {
|
|||||||
while true; do
|
while true; do
|
||||||
# Iterate over each environment variable matching 'REPO_[0-9]+'
|
# Iterate over each environment variable matching 'REPO_[0-9]+'
|
||||||
env | grep '^REPO_[0-9]\+=' | while IFS='=' read -r name value; do
|
env | grep '^REPO_[0-9]\+=' | while IFS='=' read -r name value; do
|
||||||
IFS=',' read -ra REPO_DEST <<< "$value"
|
# Split the value by comma and read into separate variables
|
||||||
process_repo "${REPO_DEST[0]}" "${REPO_DEST[1]}"
|
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
|
done
|
||||||
|
|
||||||
# Wait for 5 seconds before the next iteration
|
# Wait for 5 seconds before the next iteration
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user