borg_exporter: improve hostname deduction

This commit is contained in:
layman 2021-12-21 09:46:00 +01:00
parent c2fedd4886
commit 457509b217

View file

@ -17,10 +17,14 @@ if [[ -n "${REPOS[*]}" ]] ; then
fi >> "$TMP_FILE" fi >> "$TMP_FILE"
for repository in "${REPOS[@]}" ; do for repository in "${REPOS[@]}" ; do
hostname=${HOSTNAMES[$repository]:-$repository} hostname="$repository"
if [[ -n "${HOSTNAMES[@]}" ]] ; then
hostname=${HOSTNAMES[$repository]:-$repository}
fi
if [[ "$hostname" == "$repository" ]] ; then if [[ "$hostname" == "$repository" ]] ; then
hostname=${hostname/"${REPO_BASE}/"//} hostname=${hostname/"${REPO_BASE}/"//}
hostname=${hostname/"/backup"//} hostname=${hostname/"/backup"//}
hostname=${hostname//\//}
fi fi
index_base="$repository/index" index_base="$repository/index"
age_seconds="$(( $(date +%s) - $(date +%s -r "$index_base".*) ))" age_seconds="$(( $(date +%s) - $(date +%s -r "$index_base".*) ))"