From 8608b0695cac2f28781c2fc844aec08f544af8c2 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Tue, 27 Aug 2024 14:45:37 -0400 Subject: [PATCH] arc: rewrite Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 43 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index cf7a2507..e732d283 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -90,6 +90,7 @@ function backtitle() { ############################################################################### # Model Selection function arcModel() { + CHANGED=false dialog --backtitle "$(backtitle)" --title "DSM Model" \ --infobox "Reading Models..." 3 25 # Loop menu @@ -206,44 +207,51 @@ function arcModel() { MODELID=$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/') writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" + writeConfigKey "buildnum" "" "${USER_CONFIG_FILE}" + writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" + writeConfigKey "emmcboot" "false" "${USER_CONFIG_FILE}" + writeConfigKey "hddsort" "false" "${USER_CONFIG_FILE}" + writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" writeConfigKey "paturl" "" "${USER_CONFIG_FILE}" writeConfigKey "pathash" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" - writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" + writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" + writeConfigKey "sn" "" "${USER_CONFIG_FILE}" writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" + CHANGED=true elif [ "${MODEL}" != "${resp}" ]; then PRODUCTVER="" MODEL="${resp}" PLATFORM="$(grep -w "${MODEL}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" - writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" - writeConfigKey "modelid" "" "${USER_CONFIG_FILE}" - writeConfigKey "productver" "" "${USER_CONFIG_FILE}" - writeConfigKey "buildnum" "" "${USER_CONFIG_FILE}" - writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" - writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" + writeConfigKey "buildnum" "" "${USER_CONFIG_FILE}" writeConfigKey "emmcboot" "false" "${USER_CONFIG_FILE}" writeConfigKey "hddsort" "false" "${USER_CONFIG_FILE}" writeConfigKey "kernel" "official" "${USER_CONFIG_FILE}" + writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" + writeConfigKey "modelid" "" "${USER_CONFIG_FILE}" writeConfigKey "odp" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" writeConfigKey "paturl" "" "${USER_CONFIG_FILE}" writeConfigKey "pathash" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" - writeConfigKey "sn" "" "${USER_CONFIG_FILE}" writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" + writeConfigKey "productver" "" "${USER_CONFIG_FILE}" writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" + writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" + writeConfigKey "sn" "" "${USER_CONFIG_FILE}" writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" + CHANGED=true fi - if [ -f "${ORI_ZIMAGE_FILE}" ] || [ -f "${ORI_RDGZ_FILE}" ] || [ -f "${MOD_ZIMAGE_FILE}" ] || [ -f "${MOD_RDGZ_FILE}" ]; then + if [ "${CHANGED}" == "true" ]; then rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true fi - # Reset Cmdline - writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" + # Read Platform Data ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" @@ -289,6 +297,13 @@ function arcVersion() { writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}" NANOVER="${opt}" writeConfigKey "nanover" "${NANOVER}" "${USER_CONFIG_FILE}" + # Reset Config if changed + writeConfigKey "buildnum" "" "${USER_CONFIG_FILE}" + writeConfigKey "paturl" "" "${USER_CONFIG_FILE}" + writeConfigKey "pathash" "" "${USER_CONFIG_FILE}" + writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" + writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" + writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" # Delete old files rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true