chore: initial repo setup with baseline config backup
- Pull current config from router (OpenWRT 24.10.2) - Add backup, safe-apply, and push-all scripts - Add CLAUDE.md with workflow rules and context - Add network-map.md with current topology and planned VLANs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
scripts/backup.sh
Executable file
29
scripts/backup.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pull current router config into config/ and commit if there are changes.
|
||||
set -euo pipefail
|
||||
|
||||
ROUTER="${ROUTER:-openwrt}"
|
||||
CONFIGS=(dhcp dropbear firewall network system wireless)
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CONFIG_DIR="$SCRIPT_DIR/../config"
|
||||
|
||||
echo "Pulling config from $ROUTER..."
|
||||
for f in "${CONFIGS[@]}"; do
|
||||
ssh "$ROUTER" "cat /etc/config/$f" > "$CONFIG_DIR/$f"
|
||||
echo " $f"
|
||||
done
|
||||
|
||||
cd "$SCRIPT_DIR/.."
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
echo "No changes — config is up to date."
|
||||
else
|
||||
echo ""
|
||||
git diff --stat config/
|
||||
echo ""
|
||||
read -rp "Commit these changes? [y/N] " answer
|
||||
if [[ "${answer,,}" == "y" ]]; then
|
||||
git add config/
|
||||
git commit -m "backup: pull config from router $(date '+%Y-%m-%d %H:%M')"
|
||||
echo "Committed."
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user