From 0526fc732a8bafe542155c22d8ea4876d14465ef Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 30 Aug 2024 22:15:01 +0200 Subject: [PATCH] arc: add url sanity check Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 31ced399..84aa5c90 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -314,9 +314,20 @@ function arcVersion() { [ $? -eq 0 ] && continue # yes-button return 1 else - PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join(" ")')" + PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join("\n")')" + touch "${TMP_PATH}/versions" + while IFS= read -r line; do + VERSION="${line}" + CHECK_URL=$(echo "${PJ}" | jq -r ".\"${VERSION}\".url") + if curl --head -skL -m 5 "${CHECK_URL}" | head -n 1 | grep -q "404\|403"; then + continue + else + echo "${VERSION}" >>"${TMP_PATH}/versions" + fi + done < <(echo "${PVS}") + DSMPVS="$(cat ${TMP_PATH}/versions)" dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ - --no-items --menu "Choose a DSM Build" 0 0 0 ${PVS} \ + --no-items --menu "Choose a DSM Build" 0 0 0 ${DSMPVS} \ 2>${TMP_PATH}/resp RET=$? [ ${RET} -ne 0 ] && return