From 6f074c5846c18fb0bf07c261526fb852c028e452 Mon Sep 17 00:00:00 2001 From: Ing Date: Thu, 18 Apr 2024 05:48:33 +0800 Subject: [PATCH] fix downloadExts --- files/initrd/opt/rr/boot.sh | 6 +++--- files/initrd/opt/rr/menu.sh | 42 ++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/files/initrd/opt/rr/boot.sh b/files/initrd/opt/rr/boot.sh index e0450814..b9e48597 100755 --- a/files/initrd/opt/rr/boot.sh +++ b/files/initrd/opt/rr/boot.sh @@ -263,13 +263,13 @@ else fi # Executes DSM kernel via KEXEC + KEXECARGS="" KVER=$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver") if [ "${KVER:0:1}" = "3" -a ${EFI} -eq 1 ]; then echo -e "\033[1;33m$(TEXT "Warning, running kexec with --noefi param, strange things will happen!!")\033[0m" - kexec --noefi -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog - else - kexec -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog + KEXECARGS="--noefi" fi + kexec ${KEXECARGS} -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog echo -e "\033[1;37m$(TEXT "Booting ...")\033[0m" for T in $(w 2>/dev/null | grep -v "TTY" | awk -F' ' '{print $2}'); do echo -e "\n\033[1;43m$(TEXT "[This interface will not be operational. Please wait a few minutes.\nFind DSM via http://find.synology.com/ or Synology Assistant and connect.]")\033[0m\n" >"/dev/${T}" 2>/dev/null || true diff --git a/files/initrd/opt/rr/menu.sh b/files/initrd/opt/rr/menu.sh index 8d54222e..35f3f381 100755 --- a/files/initrd/opt/rr/menu.sh +++ b/files/initrd/opt/rr/menu.sh @@ -2686,7 +2686,7 @@ function downloadExts() { else MSG="" MSG+="Latest: ${TAG}\n\n" - MSG+="$(curl -skL --connect-timeout 10 "${PROXY}${3}/releases/tag/${TAG}" | pup 'div[data-test-selector="body-content"]' | html2text -utf8)\n\n" + MSG+="$(curl -skL --connect-timeout 10 "${PROXY}${3}/releases/tag/${TAG}" | pup 'div[data-test-selector="body-content"]' | html2text --ignore-links --ignore-images)\n\n" MSG+="$(TEXT "Do you want to update?")" if [ "${5}" = "-1" ]; then echo "${T} - ${MSG}" @@ -2699,35 +2699,35 @@ function downloadExts() { --infobox "$(echo -e "${MSG}")" 0 0 fi fi + function __download() { + rm -f ${TMP_PATH}/${4}*.zip + touch "${TMP_PATH}/${4}-${TAG}.zip.downloading" + STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${PROXY}${3}/releases/download/${TAG}/${4}-${TAG}.zip" -o "${TMP_PATH}/${4}-${TAG}.zip") + RET=$? + rm -f "${TMP_PATH}/${4}-${TAG}.zip.downloading" + if [ ${RET} -ne 0 -o ${STATUS:-0} -ne 200 ]; then + rm -f "${TMP_PATH}/${4}-${TAG}.zip" + MSG="$(printf "$(TEXT "Error downloading new version.\nError: %d:%d\n(Please via https://curl.se/libcurl/c/libcurl-errors.html check error description.)")" "${RET}" "${STATUS}")" + echo -e "${MSG}" > "${LOG_FILE}" + fi + return 0 + } + rm -f "${LOG_FILE}" if [ "${5}" = "-1" ]; then - ( - rm -f ${TMP_PATH}/${4}*.zip - touch "${TMP_PATH}/${4}-${TAG}.zip.downloading" - STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${PROXY}${3}/releases/download/${TAG}/${4}-${TAG}.zip" -o "${TMP_PATH}/${4}-${TAG}.zip") - RET=$? - rm -f "${TMP_PATH}/${4}-${TAG}.zip.downloading" - ) 2>&1 + __download $@ 2>&1 else - ( - rm -f ${TMP_PATH}/${4}*.zip - touch "${TMP_PATH}/${4}-${TAG}.zip.downloading" - STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${PROXY}${3}/releases/download/${TAG}/${4}-${TAG}.zip" -o "${TMP_PATH}/${4}-${TAG}.zip") - RET=$? - rm -f "${TMP_PATH}/${4}-${TAG}.zip.downloading" - ) 2>&1 | DIALOG --title "${T}" \ + __download $@ 2>&1 | DIALOG --title "${T}" \ --progressbox "$(TEXT "Downloading ...")" 20 100 fi - if [ ${RET} -ne 0 -o ${STATUS:-0} -ne 200 ]; then - rm -f "${TMP_PATH}/${4}-${TAG}.zip" - MSG="$(printf "$(TEXT "Error downloading new version.\nError: %d:%d\n(Please via https://curl.se/libcurl/c/libcurl-errors.html check error description.)")" "${RET}" "${STATUS}")" + if [ -f "${LOG_FILE}" ]; then if [ "${5}" = "-1" ]; then - echo "${T} - ${MSG}" + echo "${T} - $(cat "${LOG_FILE}")" elif [ "${5}" = "0" ]; then DIALOG --title "${T}" \ - --msgbox "${MSG}" 0 0 + --msgbox "$(cat "${LOG_FILE}")" 0 0 else DIALOG --title "${T}" \ - --infobox "${MSG}" 0 0 + --infobox "$(cat "${LOG_FILE}")" 0 0 fi return 1 fi