- 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>
30 lines
824 B
Bash
Executable File
30 lines
824 B
Bash
Executable File
#!/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
|