30 lines
1.0 KiB
Bash
Executable File
30 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sync environment from Gitea
|
|
set -e
|
|
|
|
REPO_DIR="$HOME/admin/environment"
|
|
cd "$REPO_DIR"
|
|
|
|
echo "[sync] Pulling from Gitea..."
|
|
git pull origin main 2>/dev/null || echo "[sync] Pull skipped (no changes or no network)"
|
|
|
|
echo "[sync] Syncing Caddyfile to m4mini..."
|
|
if [ -f "caddy/m4mini.Caddyfile" ]; then
|
|
# Extract just the Caddyfile content (skip the header comment)
|
|
tail -n +2 caddy/m4mini.Caddyfile > /tmp/m4mini.Caddyfile.tmp
|
|
if ! diff -q /tmp/m4mini.Caddyfile.tmp ~/momentry/etc/Caddyfile >/dev/null 2>&1; then
|
|
cp /tmp/m4mini.Caddyfile.tmp ~/momentry/etc/Caddyfile
|
|
echo "[sync] Caddyfile updated"
|
|
# Reload Caddy
|
|
launchctl bootout gui/$(id -u)/com.momentry.caddy.l4 2>/dev/null || true
|
|
sleep 1
|
|
launchctl bootstrap gui/$(id -u)/ ~/Library/LaunchAgents/com.momentry.caddy.l4.plist 2>/dev/null || true
|
|
echo "[sync] Caddy reloaded"
|
|
else
|
|
echo "[sync] Caddyfile unchanged"
|
|
fi
|
|
rm -f /tmp/m4mini.Caddyfile.tmp
|
|
fi
|
|
|
|
echo "[sync] Done"
|