summaryrefslogtreecommitdiff
path: root/backup.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-07-19 10:23:09 +0200
committerErich Eckner <git@eckner.net>2019-07-19 10:24:20 +0200
commit885d038bdd726ad50d41c9e4e16cbc91e661f8d3 (patch)
tree9be6b1c8f27c1eb6045511d201dcd030aab70ba9 /backup.in
parenta906e3d5cd23be687918037096df4ef63f8eb82f (diff)
downloadhardlinkedBackups-885d038bdd726ad50d41c9e4e16cbc91e661f8d3.tar.xz
backup.in: ignore ip versions with which we are not connected
Diffstat (limited to 'backup.in')
-rwxr-xr-xbackup.in22
1 files changed, 20 insertions, 2 deletions
diff --git a/backup.in b/backup.in
index 6c3c774..b74487a 100755
--- a/backup.in
+++ b/backup.in
@@ -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