Adjusted script
This commit is contained in:
parent
9038a7c9b2
commit
1017a471b2
3
.env
3
.env
@ -1,5 +1,4 @@
|
|||||||
REPO_URL=https://git.cyberstrawberry.net/container-registry/git-repo-updater
|
REPO_URL=https://git.cyberstrawberry.net/container-registry/git-repo-updater
|
||||||
COPY_DIR=/server
|
|
||||||
NTFY_URL=https://ntfy.cyberstrawberry.net/git-repo-updater
|
NTFY_URL=https://ntfy.cyberstrawberry.net/git-repo-updater
|
||||||
GIT_USERNAME=nicole.rappe
|
GIT_USERNAME=nicole.rappe
|
||||||
GIT_PASSWORD=REDACTED
|
GIT_PASSWORD=USE-AN-APP-PASSWORD
|
@ -11,5 +11,5 @@ services:
|
|||||||
- TZ=America/Denver
|
- TZ=America/Denver
|
||||||
image: git.cyberstrawberry.net/container-registry/git-repo-updater:latest
|
image: git.cyberstrawberry.net/container-registry/git-repo-updater:latest
|
||||||
volumes:
|
volumes:
|
||||||
- /srv/containers/git-repo-updater:/server
|
- /srv/containers/git-repo-updater:/DATA
|
||||||
restart: always
|
restart: always
|
@ -1,26 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
# Make DATA directory at root directory
|
||||||
# Fetch environment variables
|
mkdir -p /DATA
|
||||||
repo_url=$REPO_URL
|
|
||||||
copy_dir=$COPY_DIR
|
|
||||||
ntfy_url=$NTFY_URL
|
|
||||||
git_username=$GIT_USERNAME
|
|
||||||
git_password=$GIT_PASSWORD
|
|
||||||
|
|
||||||
# Set Git credentials
|
# Set Git credentials
|
||||||
git config --global credential.helper 'store --file /tmp/git-credentials'
|
git config --global credential.helper 'store --file /tmp/git-credentials'
|
||||||
echo "url=$repo_url" > /tmp/git-credentials
|
echo "url=$REPO_URL" > /tmp/git-credentials
|
||||||
echo "username=$git_username" >> /tmp/git-credentials
|
echo "username=$GIT_USERNAME" >> /tmp/git-credentials
|
||||||
echo "password=$git_password" >> /tmp/git-credentials
|
echo "password=$GIT_PASSWORD" >> /tmp/git-credentials
|
||||||
|
|
||||||
# Navigate to the watcher directory
|
# Navigate to the watcher directory
|
||||||
cd /root/Repo_Watcher
|
cd /root/Repo_Watcher
|
||||||
|
|
||||||
# Clone the repo if it doesn't exist
|
# Clone the repo if it doesn't exist
|
||||||
if [ ! -d "repo" ]; then
|
if [ ! -d "repo" ]; then
|
||||||
git clone $repo_url repo
|
git clone $REPO_URL repo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd repo
|
cd repo
|
||||||
@ -34,16 +29,14 @@ while true; do
|
|||||||
BASE=$(git merge-base @ @{u})
|
BASE=$(git merge-base @ @{u})
|
||||||
|
|
||||||
if [ $LOCAL = $REMOTE ]; then
|
if [ $LOCAL = $REMOTE ]; then
|
||||||
echo "Up-to-date"
|
echo "Repository Up-to-date"
|
||||||
elif [ $LOCAL = $BASE ]; then
|
elif [ $LOCAL = $BASE ]; then
|
||||||
echo "Need to pull"
|
echo "Pulling Updates from Repository..."
|
||||||
git pull origin main
|
git pull origin main
|
||||||
rsync -av --delete ./ $copy_dir
|
rsync -av --delete ./ /DATA
|
||||||
curl -d "Data updated from Git repo" $ntfy_url
|
curl -d "$REPO_URL Automatically Pulled Update" $NTFY_URL
|
||||||
elif [ $REMOTE = $BASE ]; then
|
|
||||||
echo "Need to push"
|
|
||||||
else
|
else
|
||||||
echo "Data diverged"
|
echo "Data Diverged - How exactly did this happen?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for 5 seconds before the next iteration
|
# Wait for 5 seconds before the next iteration
|
||||||
|
Loading…
x
Reference in New Issue
Block a user