diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 270a0672..3931403e 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -739,6 +739,8 @@ function backupMenu() { writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" done < <(getAllModules "${PLATFORM}" "${KVERP}") fi + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + writeConfigKey "arc.confhash" "${CONFHASHFILE}" "${USER_CONFIG_FILE}" dialog --backtitle "$(backtitle)" --title "Restore Arc Config" \ --aspect 18 --msgbox "Config restore successful!\nDownloading necessary files..." 0 0 sleep 2 @@ -818,12 +820,6 @@ function updateMenu() { 1 "Automated Update Mode" \ 2 "Full-Update Loader \Z1(update)\Zn" \ 3 "Full-Upgrade Loader \Z1(reflash)\Zn" \ - 4 "\Z4Advanced:\Zn Update Addons" \ - 5 "\Z4Advanced:\Zn Update Configs" \ - 6 "\Z4Advanced:\Zn Update LKMs" \ - 7 "\Z4Advanced:\Zn Update Modules" \ - 8 "\Z4Advanced:\Zn Update Patches" \ - 9 "\Z4Advanced:\Zn Update Custom Kernel" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && break case "$(cat ${TMP_PATH}/resp)" in @@ -886,166 +882,6 @@ function updateMenu() { exec reboot && exit 0 fi ;; - 4) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${ADDONS_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Addons" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Addons" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateAddons "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; - 5) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-configs/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${MODEL_CONFIG_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Configs" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Configs" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateConfigs "${TAG}"; then - writeConfigKey "arc.key" "" "${USER_CONFIG_FILE}" - ARCKEY="$(readConfigKey "arc.key" "${USER_CONFIG_FILE}")" - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; - 6) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-lkm/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${LKMS_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update LKMs" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update LKMs" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateLKMs "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; - 7) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-modules/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${MODULES_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Modules" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Modules" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateModules "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; - 8) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${PATCH_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Patches" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Patches" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updatePatches "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; - 9) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-custom/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${CUSTOM_PATH}/VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Custom" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Custom Kernel" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateCustom "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - fi - ;; 0) # Ask for Arc Branch ARCBRANCH="$(readConfigKey "arc.branch" "${USER_CONFIG_FILE}")" @@ -2117,12 +1953,10 @@ function decryptMenu() { writeConfigKey "arc.key" "" "${USER_CONFIG_FILE}" fi fi - SN="$(readConfigKey "sn" "${USER_CONFIG_FILE}")" - ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}")" - if [ "${SN}" != "${ARCCONF}" ]; then - writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - fi + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + writeConfigKey "arc.confhash" "${CONFHASHFILE}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ARCKEY="$(readConfigKey "arc.key" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 7d494bef..a29b6936 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -550,14 +550,46 @@ function arcPatch() { SN="$(readConfigKey "sn" "${USER_CONFIG_FILE}")" if [ "${ARCMODE}" == "automated" ]; then if [ -n "${ARCCONF}" ]; then - SN=$(generateSerial "${MODEL}" "true") + SN=$(generateSerial "${MODEL}" "true" | tr '[:lower:]' '[:upper:]') writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" else - SN=$(generateSerial "${MODEL}" "false") + SN=$(generateSerial "${MODEL}" "false" | tr '[:lower:]' '[:upper:]') writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" fi elif [ "${ARCMODE}" == "config" ]; then - if [ -n "${ARCCONF}" ]; then + CONFIGSVERSION="$(cat "${MODEL_CONFIG_PATH}/VERSION" | sed -e 's/\.//g' | sed 's/[^0-9]*//g' )" + LOADERVERSION="$(echo "${ARC_VERSION}" | sed -e 's/\.//g' | sed 's/[^0-9]*//g' )" + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + CONFHASH="$(readConfigKey "arc.confhash" "${USER_CONFIG_FILE}")" + if [ ${CONFIGSVERSION} -lt ${LOADERVERSION} ] || [ "${CONFHASH}" != "${CONFHASHFILE}" ] || [ -z "${ARCCONF}" ]; then + dialog --clear --backtitle "$(backtitle)" \ + --nocancel --title "SN/Mac Options" \ + --menu "Please choose an Option." 8 50 0 \ + 1 "Use random SN/Mac" \ + 2 "Use my SN/Mac" \ + 2>"${TMP_PATH}/resp" + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 + if [ ${resp} -eq 1 ]; then + # Generate random Serial + SN=$(generateSerial "${MODEL}" "false" | tr '[:lower:]' '[:upper:]') + writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" + elif [ ${resp} -eq 2 ]; then + while true; do + dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \ + --inputbox "Please enter a valid SN!" 7 50 "" \ + 2>"${TMP_PATH}/resp" + [ $? -ne 0 ] && break 2 + SN="$(cat ${TMP_PATH}/resp | tr '[:lower:]' '[:upper:]')" + if [ -z "${SN}" ]; then + return + else + break + fi + done + writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}" + fi + elif [ -n "${ARCCONF}" ]; then dialog --clear --backtitle "$(backtitle)" \ --nocancel --title "SN/Mac Options"\ --menu "Please choose an Option." 7 60 0 \ @@ -590,34 +622,6 @@ function arcPatch() { done writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}" fi - elif [ -z "${ARCCONF}" ]; then - dialog --clear --backtitle "$(backtitle)" \ - --nocancel --title "SN/Mac Options" \ - --menu "Please choose an Option." 8 50 0 \ - 1 "Use random SN/Mac" \ - 2 "Use my SN/Mac" \ - 2>"${TMP_PATH}/resp" - resp=$(cat ${TMP_PATH}/resp) - [ -z "${resp}" ] && return 1 - if [ ${resp} -eq 1 ]; then - # Generate random Serial - SN=$(generateSerial "${MODEL}" "false" | tr '[:lower:]' '[:upper:]') - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - elif [ ${resp} -eq 2 ]; then - while true; do - dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \ - --inputbox "Please enter a valid SN!" 7 50 "" \ - 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && break 2 - SN="$(cat ${TMP_PATH}/resp | tr '[:lower:]' '[:upper:]')" - if [ -z "${SN}" ]; then - return - else - break - fi - done - writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}" - fi fi fi writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}" @@ -712,9 +716,6 @@ function arcSettings() { deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}" deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}" fi - # Max Memory for DSM - RAMCONFIG="$((${RAMTOTAL} * 1024))" - writeConfigKey "synoinfo.mem_max_mb" "${RAMCONFIG}" "${USER_CONFIG_FILE}" if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ] && [ -n "${PLATFORM}" ] && [ -n "${KVER}" ]; then # Config is done writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}" @@ -837,11 +838,16 @@ function arcSummary() { function make() { # Check for Arc Patch ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}")" - if [ -z "${ARCCONF}" ]; then + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + CONFHASH="$(readConfigKey "arc.confhash" "${USER_CONFIG_FILE}")" + if [ -z "${ARCCONF}" ] || [ "${CONFHASH}" != "${CONFHASHFILE}" ]; then deleteConfigKey "addons.amepatch" "${USER_CONFIG_FILE}" deleteConfigKey "addons.arcdns" "${USER_CONFIG_FILE}" deleteConfigKey "addons.sspatch" "${USER_CONFIG_FILE}" fi + # Max Memory for DSM + RAMCONFIG="$((${RAMTOTAL} * 1024))" + writeConfigKey "synoinfo.mem_max_mb" "${RAMCONFIG}" "${USER_CONFIG_FILE}" # Read Model Config MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index 36a0d98f..68780b22 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -100,15 +100,15 @@ function generateSerial() { local SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}" case "${SUFFIX:-"alpha"}" in - numeric) - SERIAL+="$(random)" - ;; - alpha) - SERIAL+="$(genRandomLetter)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)" - ;; - arc) - SERIAL+="$(readConfigKey "${1}.serial" "${S_FILE}" 2>/dev/null)" - ;; + numeric) + SERIAL+="$(random)" + ;; + alpha) + SERIAL+="$(genRandomLetter)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)" + ;; + arc) + SERIAL+="$(readConfigKey "${1}.serial" "${S_FILE}" 2>/dev/null)" + ;; esac echo "${SERIAL}" @@ -161,16 +161,16 @@ function validateSerial() { return 1 fi case "${SUFFIX:-"alpha"}" in - numeric) - if ! echo "${S}" | grep -q "^[0-9]\{6\}$"; then - return 1 - fi - ;; - alpha) - if ! echo "${S}" | grep -q "^[A-Z][0-9][0-9][0-9][0-9][A-Z]$"; then - return 1 - fi - ;; + numeric) + if ! echo "${S}" | grep -q "^[0-9]\{6\}$"; then + return 1 + fi + ;; + alpha) + if ! echo "${S}" | grep -q "^[A-Z][0-9][0-9][0-9][0-9][A-Z]$"; then + return 1 + fi + ;; esac return 0 } diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 69ca6f33..2ea9910d 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -85,6 +85,7 @@ function upgradeLoader () { fi fi echo "Upgrade done! -> Rebooting..." + deleteConfigKey "arc.confhash" "${USER_CONFIG_FILE}" sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ --progressbox "Upgrading Loader..." 20 70 @@ -171,7 +172,7 @@ function updateLoader() { if [ "$(sha256sum "${TMP_PATH}/update.zip" | awk '{print $1}')" == "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" echo "Backup Arc Config File..." - cp -f "${S_FILE_ARC}" "/tmp/arc_serials.yml" + cp -f "${S_FILE}" "/tmp/serials.yml" echo "Cleaning up..." rm -rf "${ADDONS_PATH}" mkdir -p "${ADDONS_PATH}" @@ -198,7 +199,9 @@ function updateLoader() { done < <(getAllModules "${PLATFORM}" "${KVERP}") fi echo "Restore Arc Config File..." - cp -f "/tmp/arc_serials.yml" "${S_FILE_ARC}" + cp -f "/tmp/serials.yml" "${S_FILE}" + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + writeConfigKey "arc.confhash" "${CONFHASHFILE}" "${USER_CONFIG_FILE}" echo "Update done!" sleep 2 else @@ -569,6 +572,8 @@ function updateConfigs() { unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" rm -f "${TMP_PATH}/configs.zip" [ -n "${ARCKEY}" ] && cp -f "${TMP_PATH}/serials.yml" "${S_FILE}" + CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" + writeConfigKey "arc.confhash" "${CONFHASHFILE}" "${USER_CONFIG_FILE}" echo "Update done!" sleep 2 else diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index c0c153f9..39433bc6 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -12,6 +12,18 @@ set -e checkBootLoader || die "The loader is corrupted, please rewrite it!" BUS=$(getBus "${LOADER_DISK}") +# Sanity Check +CONFIGSVERSION="$(cat "${MODEL_CONFIG_PATH}/VERSION" | sed -e 's/\.//g' | sed 's/[^0-9]*//g' )" +LOADERVERSION="$(echo "${ARC_VERSION}" | sed -e 's/\.//g' | sed 's/[^0-9]*//g' )" +CONFHASHFILE="$(sha256sum "${S_FILE}" | awk '{print $1}')" +CONFHASH="$(readConfigKey "arc.confhash" "${USER_CONFIG_FILE}")" +[ -z "${CONFHASH}" ] && CONFHASH="${CONFHASHFILE}" +if [ ${CONFIGSVERSION} -lt ${LOADERVERSION} ] || [ "${CONFHASH}" != "${CONFHASHFILE}" ]; then + echo -e "Pirated Version of Arc Loader detected!!! Files can't be verified." + sleep 3 + exec poweroff +fi + # Check if machine has EFI [ -d /sys/firmware/efi ] && EFI=1 || EFI=0 @@ -40,6 +52,7 @@ initConfigKey "arc" "{}" "${USER_CONFIG_FILE}" initConfigKey "arc.branch" "" "${USER_CONFIG_FILE}" initConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" +initConfigKey "arc.confhash" "${CONFHASHFILE}" "${USER_CONFIG_FILE}" initConfigKey "arc.dynamic" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.ipv6" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.key" "" "${USER_CONFIG_FILE}"