From b1e43cae8bfbad546fbe560c71c698d6526f8785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 3 Sep 2024 09:52:20 +0200 Subject: [PATCH] add script to gets network restore locally --- .../local-network-restore-test.sh | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 nix/kexec-installer/local-network-restore-test.sh diff --git a/nix/kexec-installer/local-network-restore-test.sh b/nix/kexec-installer/local-network-restore-test.sh new file mode 100755 index 0000000..447ace9 --- /dev/null +++ b/nix/kexec-installer/local-network-restore-test.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env -S nix shell --inputs-from .# nixos-unstable#bash nixos-unstable#iproute2 nixos-unstable#findutils nixos-unstable#coreutils nixos-unstable#python3 nixos-unstable#jq --command bash + +set -eu +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") + +# This script can be used to see what network configuration would be restored by the restore_routes.py script for the current system. + +tmp=$(mktemp -d) +trap "rm -rf $tmp" EXIT +ip --json address >"$tmp/addrs.json" +ip -6 --json route >"$tmp/routes-v6.json" +ip -4 --json route >"$tmp/routes-v4.json" +python3 "$SCRIPT_DIR/restore_routes.py" "$tmp/addrs.json" "$tmp/routes-v4.json" "$tmp/routes-v6.json" "$tmp" +ls -la "$tmp" + +find "$tmp" -type f -name "*.json" -print0 | while IFS= read -r -d '' file; do + echo -e "\033[0;31m$(basename "$file")\033[0m" + jq . "$file" + echo "" +done + +find "$tmp" -type f -name "*.network" -print0 | while IFS= read -r -d '' file; do + echo -e "\033[0;31m$(basename "$file")\033[0m" + cat "$file" + echo "" +done