mirror of
https://github.com/RROrg/rr.git
synced 2025-06-21 05:51:05 +08:00
fix get pat data
This commit is contained in:
parent
5df48246d0
commit
2638ea3e5a
@ -233,76 +233,88 @@ function productversMenu() {
|
|||||||
[ $? -ne 0 ] && return
|
[ $? -ne 0 ] && return
|
||||||
resp=$(<${TMP_PATH}/resp)
|
resp=$(<${TMP_PATH}/resp)
|
||||||
[ -z "${resp}" ] && return
|
[ -z "${resp}" ] && return
|
||||||
|
|
||||||
|
if [ "${PRODUCTVER}" = "${resp}" ]; then
|
||||||
|
DIALOG --title "$(TEXT "Product Version")" \
|
||||||
|
--yesno "$(printf "$(TEXT "The current version has been set to %s. Do you want to reset the version?")" "${PRODUCTVER}")" 0 0
|
||||||
|
[ $? -ne 0 ] && return
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if ! arrayExistItem "${1}" ${ITEMS}; then return; fi
|
if ! arrayExistItem "${1}" ${ITEMS}; then return; fi
|
||||||
resp="${1}"
|
resp="${1}"
|
||||||
fi
|
fi
|
||||||
if [ "${PRODUCTVER}" = "${resp}" ]; then
|
|
||||||
DIALOG --title "$(TEXT "Product Version")" \
|
|
||||||
--yesno "$(printf "$(TEXT "The current version has been set to %s. Do you want to reset the version?")" "${PRODUCTVER}")" 0 0
|
|
||||||
[ $? -ne 0 ] && return
|
|
||||||
fi
|
|
||||||
local KVER=$(readModelKey "${MODEL}" "productvers.[${resp}].kver")
|
local KVER=$(readModelKey "${MODEL}" "productvers.[${resp}].kver")
|
||||||
if [ -d "/sys/firmware/efi" -a "${KVER:0:1}" = "3" ]; then
|
if [ -d "/sys/firmware/efi" -a "${KVER:0:1}" = "3" ]; then
|
||||||
DIALOG --title "$(TEXT "Product Version")" \
|
if [ -z "${1}" ]; then
|
||||||
--msgbox "$(TEXT "This version does not support UEFI startup, Please select another version or switch the startup mode.")" 0 0
|
DIALOG --title "$(TEXT "Product Version")" \
|
||||||
|
--msgbox "$(TEXT "This version does not support UEFI startup, Please select another version or switch the startup mode.")" 0 0
|
||||||
|
fi
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# if [ ! "usb" = "$(getBus "${LOADER_DISK}")" -a "${KVER:0:1}" = "5" ]; then
|
# if [ ! "usb" = "$(getBus "${LOADER_DISK}")" -a "${KVER:0:1}" = "5" ]; then
|
||||||
# DIALOG --title "$(TEXT "Product Version")" \
|
# if [ -z "${1}" ]; then
|
||||||
# --msgbox "$(TEXT "This version only support usb startup, Please select another version or switch the startup mode.")" 0 0
|
# DIALOG --title "$(TEXT "Product Version")" \
|
||||||
# # return
|
# --msgbox "$(TEXT "This version only support usb startup, Please select another version or switch the startup mode.")" 0 0
|
||||||
|
# fi
|
||||||
|
# return
|
||||||
# fi
|
# fi
|
||||||
while true; do
|
if [ -z "${2}" -a -z "${3}" ]; then
|
||||||
# get online pat data
|
while true; do
|
||||||
DIALOG --title "$(TEXT "Product Version")" \
|
# get online pat data
|
||||||
--infobox "$(TEXT "Get pat data ...")" 0 0
|
idx=1
|
||||||
idx=0
|
NETERR=0
|
||||||
NETERR=0
|
while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break
|
||||||
while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break
|
DIALOG --title "$(TEXT "Product Version")" \
|
||||||
fastest=$(_get_fastest "www.synology.com" "www.synology.cn")
|
--infobox "$(TEXT "Get pat data ...") (${idx}/3)" 0 0
|
||||||
if [ $? -ne 0 ]; then
|
idx=$((${idx} + 1))
|
||||||
NETERR=1
|
NETERR=0
|
||||||
continue
|
fastest=$(_get_fastest "www.synology.com" "www.synology.cn")
|
||||||
fi
|
if [ $? -ne 0 ]; then
|
||||||
[ "${fastest}" = "www.synology.cn" ] &&
|
NETERR=1
|
||||||
fastest="https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn" ||
|
continue
|
||||||
fastest="https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
|
|
||||||
patdata=$(curl -skL --connect-timeout 10 "${fastest}&product=${MODEL/+/%2B}&major=${resp%%.*}&minor=${resp##*.}")
|
|
||||||
if [ "$(echo ${patdata} | jq -r '.success' 2>/dev/null)" = "true" ]; then
|
|
||||||
if echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].label_ext' 2>/dev/null | grep -q 'pat'; then
|
|
||||||
paturl=$(echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].url')
|
|
||||||
patsum=$(echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].checksum')
|
|
||||||
paturl=${paturl%%\?*}
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
fi
|
[ "${fastest}" = "www.synology.cn" ] &&
|
||||||
idx=$((${idx} + 1))
|
fastest="https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn" ||
|
||||||
done
|
fastest="https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
|
||||||
if [ -z "${paturl}" -o -z "${patsum}" ]; then
|
patdata=$(curl -skL --connect-timeout 10 "${fastest}&product=${MODEL/+/%2B}&major=${resp%%.*}&minor=${resp##*.}")
|
||||||
if [ ${NETERR} -ne 0 ]; then
|
if [ "$(echo ${patdata} | jq -r '.success' 2>/dev/null)" = "true" ]; then
|
||||||
MSG=""
|
if echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].label_ext' 2>/dev/null | grep -q 'pat'; then
|
||||||
MSG+="$(TEXT "Network error, please check the network connection and try again.")"
|
paturl=$(echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].url')
|
||||||
MSG+="\n$(TEXT "Or use 'Parse pat' function for installation.")"
|
patsum=$(echo ${patdata} | jq -r '.info.system.detail[0].items[0].files[0].checksum')
|
||||||
|
paturl=${paturl%%\?*}
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "${paturl}" -o -z "${patsum}" ]; then
|
||||||
|
if [ ${NETERR} -ne 0 ]; then
|
||||||
|
MSG=""
|
||||||
|
MSG+="$(TEXT "Network error, please check the network connection and try again.")"
|
||||||
|
MSG+="\n$(TEXT "Or use 'Parse pat' function for installation.")"
|
||||||
|
else
|
||||||
|
MSG="$(TEXT "Failed to get pat data,\nPlease manually fill in the URL and md5sum of the corresponding version of pat.\nOr click 'Retry'.")"
|
||||||
|
fi
|
||||||
|
paturl=""
|
||||||
|
patsum=""
|
||||||
else
|
else
|
||||||
MSG="$(TEXT "Failed to get pat data,\nPlease manually fill in the URL and md5sum of the corresponding version of pat.\nOr click 'Retry'.")"
|
MSG="$(TEXT "Successfully to get pat data, Please confirm.\nOr modify the URL and md5sum to you need.")"
|
||||||
fi
|
fi
|
||||||
paturl=""
|
DIALOG --title "$(TEXT "Product Version")" \
|
||||||
patsum=""
|
--extra-button --extra-label "$(TEXT "Retry")" \
|
||||||
else
|
--form "${MSG}" 10 110 2 "URL" 1 1 "${paturl}" 1 5 100 0 "MD5" 2 1 "${patsum}" 2 5 100 0 \
|
||||||
MSG="$(TEXT "Successfully to get pat data, Please confirm.\nOr modify the URL and md5sum to you need.")"
|
2>"${TMP_PATH}/resp"
|
||||||
fi
|
RET=$?
|
||||||
DIALOG --title "$(TEXT "Product Version")" \
|
[ ${RET} -eq 0 ] && break # ok-button
|
||||||
--extra-button --extra-label "$(TEXT "Retry")" \
|
[ ${RET} -eq 3 ] && continue # extra-button
|
||||||
--form "${MSG}" 10 110 2 "URL" 1 1 "${paturl}" 1 5 100 0 "MD5" 2 1 "${patsum}" 2 5 100 0 \
|
return # 1 or 255 # cancel-button or ESC
|
||||||
2>"${TMP_PATH}/resp"
|
done
|
||||||
RET=$?
|
paturl="$(cat "${TMP_PATH}/resp" | sed -n '1p')"
|
||||||
[ ${RET} -eq 0 ] && break # ok-button
|
patsum="$(cat "${TMP_PATH}/resp" | sed -n '2p')"
|
||||||
[ ${RET} -eq 3 ] && continue # extra-button
|
else
|
||||||
return # 1 or 255 # cancel-button or ESC
|
paturl="${2}"
|
||||||
done
|
patsum="${3}"
|
||||||
paturl="$(cat "${TMP_PATH}/resp" | sed -n '1p')"
|
fi
|
||||||
patsum="$(cat "${TMP_PATH}/resp" | sed -n '2p')"
|
|
||||||
[ -z "${paturl}" -o -z "${patsum}" ] && return
|
[ -z "${paturl}" -o -z "${patsum}" ] && return
|
||||||
writeConfigKey "paturl" "${paturl}" "${USER_CONFIG_FILE}"
|
writeConfigKey "paturl" "${paturl}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "patsum" "${patsum}" "${USER_CONFIG_FILE}"
|
writeConfigKey "patsum" "${patsum}" "${USER_CONFIG_FILE}"
|
||||||
@ -312,8 +324,10 @@ function productversMenu() {
|
|||||||
SMALLNUM=""
|
SMALLNUM=""
|
||||||
writeConfigKey "buildnum" "${BUILDNUM}" "${USER_CONFIG_FILE}"
|
writeConfigKey "buildnum" "${BUILDNUM}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "smallnum" "${SMALLNUM}" "${USER_CONFIG_FILE}"
|
writeConfigKey "smallnum" "${SMALLNUM}" "${USER_CONFIG_FILE}"
|
||||||
DIALOG --title "$(TEXT "Product Version")" \
|
if [ -z "${1}" ]; then
|
||||||
--infobox "$(TEXT "Reconfiguring Synoinfo, Addons and Modules")" 0 0
|
DIALOG --title "$(TEXT "Product Version")" \
|
||||||
|
--infobox "$(TEXT "Reconfiguring Synoinfo, Addons and Modules")" 0 0
|
||||||
|
fi
|
||||||
# Delete synoinfo and reload model/build synoinfo
|
# Delete synoinfo and reload model/build synoinfo
|
||||||
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
|
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
|
||||||
while IFS=': ' read KEY VALUE; do
|
while IFS=': ' read KEY VALUE; do
|
||||||
@ -2904,6 +2918,10 @@ if [ "${1}" = "update" ]; then
|
|||||||
updateMenu "${EXT}"
|
updateMenu "${EXT}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
if [ "${1}" = "make" -a -n "${MODEL}" -a -n "${PRODUCTVER}" -a loaderIsConfigured ]; then
|
||||||
|
make
|
||||||
|
exit
|
||||||
|
fi
|
||||||
if [ "${1}" = "boot" -a -n "${MODEL}" -a -n "${PRODUCTVER}" -a loaderIsConfigured ]; then
|
if [ "${1}" = "boot" -a -n "${MODEL}" -a -n "${PRODUCTVER}" -a loaderIsConfigured ]; then
|
||||||
make
|
make
|
||||||
boot && exit 0 || sleep 5
|
boot && exit 0 || sleep 5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user