diff options
author | Erich Eckner <git@eckner.net> | 2019-07-19 10:23:09 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-07-19 10:24:20 +0200 |
commit | 885d038bdd726ad50d41c9e4e16cbc91e661f8d3 (patch) | |
tree | 9be6b1c8f27c1eb6045511d201dcd030aab70ba9 | |
parent | a906e3d5cd23be687918037096df4ef63f8eb82f (diff) | |
download | hardlinkedBackups-885d038bdd726ad50d41c9e4e16cbc91e661f8d3.tar.xz |
backup.in: ignore ip versions with which we are not connected
-rwxr-xr-x | backup.in | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -70,6 +70,19 @@ extract_ssh_ip_protocols() { fi } +connected_ip_versions() { + ip -o addr show scope global \ + | awk '{print $4}' \ + | sed ' + s@^\([0-9]\+\.\)\{3\}[0-9]\+\(/[0-9]\+\)\?$@4@ + t + s@^[0-9a-f][0-9a-f:]\+\(/[0-9]\+\)\?$@6@ + t + d + ' \ + | sort -u +} + if [ $# -eq 1 ]; then if [ "$1" == "--help" ]; then usage 0 @@ -101,8 +114,13 @@ QuellIP=$(echo "$3" | sed "s|^[a-zA-Z]*://||; s|^[a-zA-Z]*@||; s|:\?/.*$||") if [ "$#" -eq 3 ]; then Quelle="$3" ipVer=$( - extract_ssh_ip_protocols "${QuellIP}" \ - | sort -n \ + { + extract_ssh_ip_protocols "${QuellIP}" \ + | sort -n + extract_ssh_ip_protocols "${QuellIP}" \ + | grep -xF "$(connected_ip_versions)" \ + | sort -n + } \ | tail -n1 ) elif [ "$#" -eq 4 ]; then |