From 442c44aad056639748f91ca39c681215f042fc86 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 14 May 2019 15:55:47 +0200 Subject: archive: symlinks for last, week and month repos --- archive | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/archive b/archive index 4b7aef4..c2e810e 100755 --- a/archive +++ b/archive @@ -86,6 +86,46 @@ if [ ! -d "${todays_path}" ]; then done done done + rm -f \ + "${archive_root}/repos/last" \ + "${archive_root}/repos/week" \ + "${archive_root}/repos/month" + ln -s \ + "${todays_path}" \ + "${archive_root}/repos/last" + first_of_month=$( + find "${archive_root}/repos" -mindepth 3 -maxdepth 3 \ + | sed ' + s,^.*/\([^/]\+\)/\([^/]\+\)/\([^/]\+\)$,\1/\2 \3, + t + d + ' \ + | sort -k1r,1 -k2,2 \ + | head -n1 \ + | tr ' ' '/' + ) + ln -s \ + "${archive_root}/repos/${first_of_month}" \ + "${archive_root}/repos/month" + first_of_week=$( + find "${archive_root}/repos" -mindepth 3 -maxdepth 3 \ + | sed ' + s,^.*/\([^/]\+\)/\([^/]\+\)/\([^/]\+\)$,\1-\2-\3, + t + d + ' \ + | sort \ + | tail -n7 \ + | while read -r date; do + date '+%Y/%m/%d %G %V' -d "${date}" + done \ + | sort -k2r,3 -k1,1 \ + | head -n1 \ + | cut -d' ' -f1 + ) + ln -s \ + "${archive_root}/repos/${first_of_week}" \ + "${archive_root}/repos/week" fi # release lock -- cgit v1.2.3