#!/bin/bash # Copies system config files into the repo and commits if anything changed. # File mapping is defined in system/tracked-configs. # Intended to run via cron (e.g., daily). set -euo pipefail REPO="/opt/argento" # Copy each tracked config into the repo while IFS=: read -r src dest; do [ -z "$src" ] && continue [[ "$src" = \#* ]] && continue if [ -f "$src" ]; then cp "$src" "$REPO/$dest" fi done < "$REPO/system/tracked-configs" sed -i 's/^password .*/password REDACTED/' "$REPO/system/msmtprc" # Sync root crontab crontab -l > "$REPO/system/root-crontab" 2>/dev/null || true cd "$REPO" # Stage and check if anything changed git add system/ if git diff --cached --quiet; then exit 0 fi git commit -m "auto: sync system configs" git push || echo "Push failed (remote ahead?) — committed locally, will push next time."