From 95c1eb68978afc6d617e2e072e4914c0ea1f7be0 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 13 Nov 2024 18:05:58 +0100 Subject: [PATCH] tree: rework more Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 70 ++++++++++++++------------ files/initrd/opt/arc/arc.sh | 11 ++-- files/initrd/opt/arc/boot.sh | 2 +- files/initrd/opt/arc/include/update.sh | 3 +- files/initrd/opt/arc/init.sh | 3 +- 5 files changed, 48 insertions(+), 41 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index c101cb80..7f61a193 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -828,13 +828,14 @@ function backupMenu() { dialog --backtitle "$(backtitle)" --title "Online Restore" --msgbox "Online Restore successful!" 5 40 else dialog --backtitle "$(backtitle)" --title "Online Restore" --msgbox "Online Restore failed!" 5 40 - mv -f "${USER_CONFIG_FILE}.bak" "${USER_CONFIG_FILE}" + [ -f "${USER_CONFIG_FILE}.bak" ] && mv -f "${USER_CONFIG_FILE}.bak" "${USER_CONFIG_FILE}" fi ;; 5) if [ -f "${USER_CONFIG_FILE}" ]; then HWID="$(genHWID)" - if curl -sk -X POST -F "file=@${USER_CONFIG_FILE}" "https://arc.auxxxilium.tech?cup=${HWID}&userid=${USERID}"; then + curl -sk -X POST -F "file=@${USER_CONFIG_FILE}" "https://arc.auxxxilium.tech?cup=${HWID}&userid=${USERID}" 2>/dev/null + if [ $? -eq 0 ]; then dialog --backtitle "$(backtitle)" --title "Online Backup" --msgbox "Online Backup successful!" 5 40 else dialog --backtitle "$(backtitle)" --title "Online Backup" --msgbox "Online Backup failed!" 5 40 @@ -1227,7 +1228,8 @@ function getCMDline () { function uploadDiag () { if [ -f "${TMP_PATH}/sysinfo.yml" ]; then HWID="$(genHWID)" - if curl -sk -X POST -F "file=@${TMP_PATH}/sysinfo.yml" "https://arc.auxxxilium.tech?sysinfo=${HWID}&userid=${USERID}"; then + curl -sk -X POST -F "file=@${TMP_PATH}/sysinfo.yml" "https://arc.auxxxilium.tech?sysinfo=${HWID}&userid=${USERID}" 2>/dev/null + if [ $? -eq 0 ]; then dialog --backtitle "$(backtitle)" --title "Sysinfo Upload" --msgbox "Your Code: ${HWID}" 5 40 else dialog --backtitle "$(backtitle)" --title "Sysinfo Upload" --msgbox "Failed to upload diag file!" 0 0 @@ -2221,7 +2223,7 @@ function getpatfiles() { --infobox "Downloading DSM Boot Files..." 3 40 # Get new Files DSM_URL="https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/files/${MODEL/+/%2B}/${PRODUCTVER}/${PAT_HASH}.tar" - if curl -skL "${DSM_URL}" -o "${DSM_FILE}"; then + if curl -skL "${DSM_URL}" -o "${DSM_FILE}" 2>/dev/null; then VALID="true" fi elif [ ! -f "${DSM_FILE}" ] && [ "${ARCOFFLINE}" == "true" ]; then @@ -2256,28 +2258,31 @@ function getpatfiles() { # Generate HardwareID function genHardwareID() { HWID="$(genHWID)" - if [ -n "${HWID}" ]; then - USERID="$(curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}")" - if echo "${USERID}" | grep -vq "Hardware ID"; then - dialog --backtitle "$(backtitle)" --title "HardwareID" \ - --msgbox "HardwareID: ${HWID}\nYour HardwareID is registered to UserID: ${USERID}!" 6 70 - writeConfigKey "arc.hwid" "${HWID}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.userid" "${USERID}" "${USER_CONFIG_FILE}" + while true; do + if [ -n "${HWID}" ]; then + USERID="$(curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}" 2>/dev/null)" + if echo "${USERID}" | grep -vq "Hardware ID"; then + dialog --backtitle "$(backtitle)" --title "HardwareID" \ + --msgbox "HardwareID: ${HWID}\nYour HardwareID is registered to UserID: ${USERID}!" 6 70 + writeConfigKey "arc.hwid" "${HWID}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.userid" "${USERID}" "${USER_CONFIG_FILE}" + break + else + dialog --backtitle "$(backtitle)" --title "HardwareID" \ + --yes-label "Retry" --no-label "Cancel" --yesno "HardwareID: ${HWID}\nRegister your HardwareID on\nhttps://arc.auxxxilium.tech (Discord Account needed)." 7 60 + [ $? -ne 0 ] && USERID="" && break + writeConfigKey "arc.hwid" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" + fi else dialog --backtitle "$(backtitle)" --title "HardwareID" \ - --yes-label "Retry" --no-label "Cancel" --yesno "HardwareID: ${HWID}\nRegister your HardwareID on\nhttps://arc.auxxxilium.tech (Discord Account needed)." 8 60 - [ $? -ne 0 ] && USERID="" && return 1 + --msgbox "HardwareID: ID Generation failed!" 6 50 + USERID="" writeConfigKey "arc.hwid" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" - genHardwareID + break fi - else - dialog --backtitle "$(backtitle)" --title "HardwareID" \ - --msgbox "HardwareID: Verification failed!" 6 50 - USERID="" - writeConfigKey "arc.hwid" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" - fi + done return } @@ -2285,30 +2290,29 @@ function genHardwareID() { # Check HardwareID function checkHardwareID() { HWID="$(genHWID)" - USERID="$(curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}")" + USERID="$(curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}" 2>/dev/null)" if echo "${USERID}" | grep -vq "Hardware ID"; then - writeConfigKey "arc.hwid" "${HWID}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.userid" "${USERID}" "${USER_CONFIG_FILE}" cp -f "${S_FILE}" "${S_FILE}.bak" - if curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}&userid=${USERID}" > "${S_FILE}"; then + if curl -skL "https://arc.auxxxilium.tech?hwid=${HWID}&userid=${USERID}" -o "${S_FILE}" 2>/dev/null; then dialog --backtitle "$(backtitle)" --title "HardwareID" \ --infobox "HardwareID: ${HWID}\nYour HardwareID is registered to UserID: ${USERID}!" 6 70 - sleep 3 + writeConfigKey "arc.hwid" "${HWID}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.userid" "${USERID}" "${USER_CONFIG_FILE}" else + dialog --backtitle "$(backtitle)" --title "HardwareID" \ + --infobox "HardwareID: Your HardwareID couldn't be verified!" 6 50 + USERID="" writeConfigKey "arc.hwid" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" - dialog --backtitle "$(backtitle)" --title "HardwareID" \ - --infobox "Couldn't verify your HardwareID!\nArc Patch not enabled!" 6 40 - USERID="" - cp -f "${S_FILE}.bak" "${S_FILE}" - sleep 3 fi else dialog --backtitle "$(backtitle)" --title "HardwareID" \ - --infobox "HardwareID: Verification failed!" 6 50 + --infobox "HardwareID: Your HardwareID isn't registered!" 6 50 USERID="" - sleep 2 + writeConfigKey "arc.hwid" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" fi + sleep 3 return } diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index eb8f0a7a..f2f799d5 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -94,6 +94,8 @@ function arcModel() { if [ ! -f "${S_FILE}" ] || [ ! -f "${P_FILE}" ]; then updateConfigs fi + # Check for Hardware ID + checkHardwareID # Loop menu RESTRICT=1 PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)" @@ -151,14 +153,15 @@ function arcModel() { fi [ -n "$(grep -w "${M}" "${S_FILE}")" ] && BETA="Arc" || BETA="Syno" [ -z "$(grep -w "${A}" "${P_FILE}")" ] && COMPATIBLE=0 - if [ -n "${ARCKEY}" ]; then + if [ -n "${ARCCONF}" ]; then [ ${COMPATIBLE} -eq 1 ] && echo -e "${M} \"\t$(printf "\Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "${A}" "${DTS}" "${ARC}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}" "${BETA}")\" ">>"${TMP_PATH}/menu" else [ ${COMPATIBLE} -eq 1 ] && echo -e "${M} \"\t$(printf "\Zb%-15s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "${A}" "${DTS}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}" "${BETA}")\" ">>"${TMP_PATH}/menu" fi done < <(cat "${TMP_PATH}/modellist") - [ -n "${ARCKEY}" ] && MSG="Supported Models for your Hardware (x = supported / + = need Addons)\n$(printf "\Zb%-16s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "Model" "Platform" "DT" "Arc" "Intel iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Source")" || MSG="Supported Models for your Hardware (x = supported / + = need Addons) | Syno Models can have faulty Values.\n$(printf "\Zb%-16s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "Model" "Platform" "DT" "Intel iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Source")" - [ -n "${ARCKEY}" ] && TITLEMSG="Arc Model" || TITLEMSG="Model" + ARCCONF="$(readConfigKey "${MODEL:-SA6400}.serial" "${S_FILE}")" + [ -n "${ARCCONF}" ] && MSG="Supported Models for your Hardware (x = supported / + = need Addons)\n$(printf "\Zb%-16s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "Model" "Platform" "DT" "Arc" "Intel iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Source")" || MSG="Supported Models for your Hardware (x = supported / + = need Addons) | Syno Models can have faulty Values.\n$(printf "\Zb%-16s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-12s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "Model" "Platform" "DT" "Intel iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Source")" + [ -n "${ARCCONF}" ] && TITLEMSG="Arc Model" || TITLEMSG="Model" dialog --backtitle "$(backtitlep)" --title "${TITLEMSG}" --colors \ --cancel-label "Show all" --help-button --help-label "Exit" \ --extra-button --extra-label "Info" \ @@ -671,7 +674,7 @@ function make() { SN="$(readConfigKey "sn" "${USER_CONFIG_FILE}")" BOOTMODE="$(readConfigKey "arc.mode" "${USER_CONFIG_FILE}")" if [ "${BOOTMODE}" != "automated" ] && [ "${ARCOFFLINE}" != "true" ] && [[ "${ARCPATCH}" != "true" || -z "${ARCCONF}" ]]; then - if ! curl -skL "https://auxxxilium.tech/check.yml" -o "${TMP_PATH}/check.yml" 2>/dev/null; then + if ! curl -skL "https://arc.auxxxilium.tech/check.yml" -o "${TMP_PATH}/check.yml" 2>/dev/null; then SN=$(generateSerial "${MODEL}" "false") else if grep -q "${SN}" "${TMP_PATH}/check.yml"; then diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 76ac9ff8..88074ea7 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -326,7 +326,7 @@ elif [ "${DIRECTBOOT}" == "false" ]; then echo -e "\033[1;37mBooting DSM...\033[0m" # Boot to DSM - [ "${KERNELLOAD}" == "kexec" ] && kexec -e || poweroff + [ "${KERNELLOAD}" == "kexec" ] && exec kexec -e || exec poweroff fi exit 0 \ No newline at end of file diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 51a304b8..86c99ac0 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -319,8 +319,8 @@ function updateModules() { ############################################################################### # Update Configs function updateConfigs() { - local ARCKEY="$(readConfigKey "arc.key" "${USER_CONFIG_FILE}")" [ -f "${MODEL_CONFIG_PATH}/VERSION" ] && local CONFIGSVERSION="$(cat "${MODEL_CONFIG_PATH}/VERSION")" || CONFIGSVERSION="0.0.0" + local USERID="$(readConfigKey "arc.userid" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break @@ -362,6 +362,7 @@ function updateConfigs() { dialog --backtitle "$(backtitle)" --title "Update Configs" \ --infobox "Update successful!" 3 50 sleep 2 + [ -z "${USERID}" ] && checkHardwareID || true else return 1 fi diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 2fc8cff5..6d75d7de 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -38,7 +38,6 @@ initConfigKey "arc" "{}" "${USER_CONFIG_FILE}" initConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.dynamic" "false" "${USER_CONFIG_FILE}" -initConfigKey "arc.key" "" "${USER_CONFIG_FILE}" initConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.version" "${ARC_VERSION}" "${USER_CONFIG_FILE}" @@ -156,7 +155,7 @@ elif [ "${ARCMODE}" == "update" ]; then elif [ "${BUILDDONE}" == "true" ] && [ "${ARCMODE}" == "dsm" ]; then echo -e "\033[1;34mStarting DSM Mode...\033[0m" if [ -f "${ARC_PATH}/boot.sh" ]; then - boot.sh && exit 0 + exec boot.sh && exit 0 else echo -e "\033[1;31mError: Can't find Arc System Files...\033[0m" fi