From 96d693674a04a9e0a85e97a8631e8cb3ec731d9b Mon Sep 17 00:00:00 2001 From: John Adams Date: Wed, 20 Dec 2023 17:21:15 +0000 Subject: [PATCH] exit messages and file name --- mirrorly | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/mirrorly b/mirrorly index 821c351..12ef824 100755 --- a/mirrorly +++ b/mirrorly @@ -16,6 +16,7 @@ cleanup() rm "${TMP_DIR}"/*-Packages 2>/dev/null || true rm "${TMP_DIR}"/*-Release 2>/dev/null || true rm "${TMP_DIR}"/*-Sizes 2>/dev/null || true + rm "${TMP_DIR}"/*-MD5sums 2>/dev/null || true } trap_handler() @@ -23,6 +24,38 @@ trap_handler() RC="$?" trap - ERR TERM HUP INT QUIT EXIT cleanup + case "${RC}" in + "0") + echo Mirror sync successful + ;; + "1") + echo Requirements not met 1>&2 + ;; + "2") + echo Permissions error 1>&2 + ;; + "3") + echo Error in mirrorly.conf 1>&2 + ;; + "4") + echo Exit code not defined 1>&2 + ;; + "5") + echo Missing MD5SUMS 1>&2 + ;; + "6") + echo Error downloading pool files 1>&2 + ;; + "7") + echo Error downloading dist files 1>&2 + ;; + "254") + echo Ran out of retry attempts 1>&2 + ;; + *) + echo Unknown error 1>&2 + ;; + esac exit "${RC}" } @@ -241,8 +274,8 @@ stage1b() --retries "${NUM_RETRIES}" \ --joblog "${TMP_DIR}"/download-joblog \ --jobs "${DL_JOBS}" \ - get_file_from_repo - awk '{print $1"\t"$3"/"$4}' "${TMP_DIR}/need-to-download" | sort -k2 find-Sizes - | uniq > "${TMP_DIR}/combined-Sizes" + get_file_from_repo || exit 6 + awk '{print $1"\t"$3"/"$4}' "${TMP_DIR}/need-to-download" | sort -k2 file-Sizes - | uniq > "${TMP_DIR}/combined-Sizes" fi } @@ -257,7 +290,9 @@ stage2a() echo "Getting dist files..." get_release_files - echo "Downloading or checking files..." + local NUM_DIST_FILES=0 + NUM_DIST_FILES="$(wc -l "${TMP_DIR}/dists-MD5sums" | cut -d' ' -f1 | tr -d '\n')" + echo "Checking or downloading ${NUM_DIST_FILES} files..." export MIRROR_DIR export TMP_DIR export -f get_file_from_repo @@ -267,7 +302,7 @@ stage2a() --retries "${NUM_RETRIES}" \ --joblog "${TMP_DIR}"/dist-joblog \ --jobs "${DL_JOBS}" \ - get_file_from_repo + get_file_from_repo || exit 7 } stage2b()