summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-05-12 14:16:33 +0200
committerErich Eckner <git@eckner.net>2020-05-12 14:16:39 +0200
commit8b0eeb99fa2ed608054da21cea81851a361d1f71 (patch)
tree027e4535b36cdd477969d541ef2aca7b33bca8ea
parentefd134429b82fc8fd4d50d7082b2ab2c2ff108ab (diff)
downloadarch-mirror-8b0eeb99fa2ed608054da21cea81851a361d1f71.tar.xz
arch-mirror: refresh lastsync & lastupdate
-rwxr-xr-xarch-mirror34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch-mirror b/arch-mirror
index a2d9dfb..2fa45a3 100755
--- a/arch-mirror
+++ b/arch-mirror
@@ -214,3 +214,37 @@ find "${mirror_dir}" \
rm -f "${link_name}"
ln -s "${link_target}" "${link_name}"
done
+
+# refresh lastsync & lastupdate
+
+declare -A dates
+
+while read -r var date; do
+ if [ "${var}" != 'lastupdate' ] \
+ && [ "${var}" != 'lastsync' ]; then
+ continue
+ fi
+ if [ -z "${dates[${var}.min]}" ] \
+ || [ "${dates[${var}.min]}" -gt "${date}" ]; then
+ dates["${var}.min"]="${date}";
+ fi
+ if [ -z "${dates[${var}.max]}" ] \
+ || [ "${dates[${var}.max]}" -lt "${date}" ]; then
+ dates["${var}.max"]="${date}";
+ fi
+done < <(
+ find "${mirror_dir}" -maxdepth 3 \
+ -name '.*' -prune , \
+ -type f \( \
+ -name 'lastsync' -o -name 'lastupdate' \
+ \) \
+ -printf '%f ' \
+ -exec head -n1 {} \; \
+ -printf '\n' \
+ | grep -vxF ''
+)
+
+for key in "${!dates[@]}"; do
+ printf '%s\n' "${dates["${key}"]}" \
+ > "${mirror_dir}/${key}"
+done