Add Cloudflare DDNS updater scripts and systemd configurations
This commit is contained in:
29
dyndns/git-sync.sh
Normal file
29
dyndns/git-sync.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# git-sync.sh - pull changes and run deploy.sh if updated
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "${REPO_DIR}"
|
||||
|
||||
git fetch --all --prune
|
||||
|
||||
UPDATED=0
|
||||
if git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then
|
||||
LOCAL="$(git rev-parse @)"
|
||||
REMOTE="$(git rev-parse @{u})"
|
||||
if [ "${LOCAL}" != "${REMOTE}" ]; then
|
||||
UPDATED=1
|
||||
fi
|
||||
else
|
||||
out="$(git pull --rebase 2>&1 || true)"
|
||||
if ! echo "${out}" | grep -q "Already up"; then
|
||||
UPDATED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${UPDATED}" -eq 1 ]; then
|
||||
echo "$(date -Iseconds) Repo updated -> running deploy.sh"
|
||||
"${REPO_DIR}/deploy.sh"
|
||||
else
|
||||
echo "$(date -Iseconds) Repo unchanged"
|
||||
fi
|
||||
Reference in New Issue
Block a user