From 5c3e6c0aec62ce5259580402baa17c24e05c6d85 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 17:40:34 +0200 Subject: [PATCH 01/11] update: full rewrite update function Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 168 ++---------- files/initrd/opt/arc/arc.sh | 1 + files/initrd/opt/arc/include/update.sh | 338 +++++++++++++++++++++++++ files/initrd/opt/arc/update.sh | 247 +----------------- 4 files changed, 371 insertions(+), 383 deletions(-) create mode 100755 files/initrd/opt/arc/include/update.sh diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 0af4816e3..f499fadb1 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -731,10 +731,10 @@ function updateMenu() { --menu "Choose an Option" 0 0 0 \ 1 "Full-Upgrade Loader" \ 2 "Update Addons" \ - 3 "Update Patches" \ - 4 "Update Modules" \ - 5 "Update Configs" \ - 6 "Update LKMs" \ + 3 "Update Configs" \ + 4 "Update LKMs" \ + 5 "Update Modules" \ + 6 "Update Patches" \ 7 "Automated Update Mode" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 @@ -812,12 +812,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then dialog --backtitle "$(backtitle)" --title "Update Addons" \ --inputbox "Type the Version!" 0 0 \ @@ -825,37 +820,13 @@ function updateMenu() { TAG=$(cat "${TMP_PATH}/input") [ -z "${TAG}" ] && return 1 fi - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip") - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --msgbox "Error downloading Updatefile!" 0 0 - return 1 - fi - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${ADDONS_PATH}" - mkdir -p "${ADDONS_PATH}" - unzip -oq "${TMP_PATH}/addons.zip" -d "${ADDONS_PATH}" >/dev/null 2>&1 - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Installing new Addons" 0 0 - for PKG in $(ls ${ADDONS_PATH}/*.addon); do - ADDON=$(basename ${PKG} | sed 's|.addon||') - rm -rf "${ADDONS_PATH}/${ADDON:?}" - mkdir -p "${ADDONS_PATH}/${ADDON}" - tar -xaf "${PKG}" -C "${ADDONS_PATH}/${ADDON}" >/dev/null 2>&1 - rm -f "${ADDONS_PATH}/${ADDON}.addon" - done - rm -f "${TMP_PATH}/addons.zip" + updateAddons "${TAG}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --msgbox "Addons updated successful! New Version: ${TAG}" 0 0 ;; 3) # Ask for Tag - dialog --clear --backtitle "$(backtitle)" --title "Update Patches" \ + dialog --clear --backtitle "$(backtitle)" --title "Update Configs" \ --menu "Which Version?" 0 0 0 \ 1 "Latest" \ 2 "Select Version" \ @@ -863,41 +834,21 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Patches" \ + 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 - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip") - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --msgbox "Error downloading Updatefile!" 0 0 - return 1 - fi - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${PATCH_PATH}" - mkdir -p "${PATCH_PATH}" - unzip -oq "${TMP_PATH}/patches.zip" -d "${PATCH_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/patches.zip" + updateConfigs "${TAG}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --msgbox "Patches updated successful! New Version: ${TAG}" 0 0 ;; 4) # Ask for Tag - dialog --clear --backtitle "$(backtitle)" --title "Update Modules" \ + dialog --clear --backtitle "$(backtitle)" --title "Update LKMs" \ --menu "Which Version?" 0 0 0 \ 1 "Latest" \ 2 "Select Version" \ @@ -905,56 +856,21 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Modules" \ + 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 - dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip") - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ - --msgbox "Error downloading Updatefile!" 0 0 - return 1 - fi - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - if [ -n "${PRODUCTVER}" ]; then - PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" - if [ "${PLATFORM}" = "epyc7002" ]; then - KVERP="${PRODUCTVER}-${KVER}" - else - KVERP="${KVER}" - fi - fi - rm -rf "${MODULES_PATH}" - mkdir -p "${MODULES_PATH}" - unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1 - # Rebuild modules if model/build is selected - if [[-n "${PLATFORM}" ] && [ -n "${KVERP}" ]; then - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read -r ID DESC; do - writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "${KVERP}") - fi - rm -f "${TMP_PATH}/modules.zip" + updateLKMs "${TAG}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ - --msgbox "Modules updated successful. New Version: ${TAG}" 0 0 ;; 5) # Ask for Tag - dialog --clear --backtitle "$(backtitle)" --title "Update Configs" \ + dialog --clear --backtitle "$(backtitle)" --title "Update Modules" \ --menu "Which Version?" 0 0 0 \ 1 "Latest" \ 2 "Select Version" \ @@ -962,41 +878,21 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Configs" \ + 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 - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip") - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --msgbox "Error downloading Updatefile!" 0 0 - return 1 - fi - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${MODEL_CONFIG_PATH}" - mkdir -p "${MODEL_CONFIG_PATH}" - unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/configs.zip" + updateModules "${TAG}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --msgbox "Configs updated successful! New Version: ${TAG}" 0 0 ;; 6) # Ask for Tag - dialog --clear --backtitle "$(backtitle)" --title "Update LKMs" \ + dialog --clear --backtitle "$(backtitle)" --title "Update Patches" \ --menu "Which Version?" 0 0 0 \ 1 "Latest" \ 2 "Select Version" \ @@ -1004,37 +900,17 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update LKMs" \ + 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 - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${TMP_PATH}/rp-lkms.zip") - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --msgbox "Error downloading Updatefile" 0 0 - return 1 - fi - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${LKM_PATH}" - mkdir -p "${LKM_PATH}" - unzip -oq "${TMP_PATH}/rp-lkms.zip" -d "${LKM_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/rp-lkms.zip" + updatePatches "${TAG}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --msgbox "LKMs updated successful! New Version: ${TAG}" 0 0 ;; 7) dialog --backtitle "$(backtitle)" --title "Automated Update" --aspect 18 \ diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 8039b3a0f..8989fe412 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -9,6 +9,7 @@ . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/storage.sh . ${ARC_PATH}/include/network.sh +. ${ARC_PATH}/include/update.sh . ${ARC_PATH}/arc-functions.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh new file mode 100755 index 000000000..0173ae2f7 --- /dev/null +++ b/files/initrd/opt/arc/include/update.sh @@ -0,0 +1,338 @@ +[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +. ${ARC_PATH}/include/consts.sh +. ${ARC_PATH}/include/configFile.sh +. ${ARC_PATH}/include/addons.sh +. ${ARC_PATH}/include/modules.sh +. ${ARC_PATH}/include/update.sh + +CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + +############################################################################### +# Update Loader +function updateLoader() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip")" + echo "Extract Updatefile..." + unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}" >/dev/null 2>&1 + rm -f "${TMP_PATH}/update.zip" + echo "Installing new Loader Image..." + if [ -f "${TMP_PATH}/bzImage-arc" ] && [ -f "${TMP_PATH}/initrd-arc" ]; then + # Process complete update + cp -f "${TMP_PATH}/grub.cfg" "${GRUB_PATH}/grub.cfg" + cp -f "${TMP_PATH}/bzImage-arc" "${ARC_BZIMAGE_FILE}" + cp -f "${TMP_PATH}/initrd-arc" "${ARC_RAMDISK_FILE}" + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + [ -f "${TMP_PATH}/update.zip" ] && rm -f "${TMP_PATH}/update.zip" + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Loader" \ + --progressbox "Updating Loader..." 20 70 + return 0 +} + +############################################################################### +# Update Addons +function updateAddons() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip")" + rm -rf "${ADDONS_PATH}" + mkdir -p "${ADDONS_PATH}" + echo "Installing new Addons..." + unzip -oq "${TMP_PATH}/addons.zip" -d "${ADDONS_PATH}" >/dev/null 2>&1 + if [ -f "${TMP_PATH}/addons.zip" ]; then + rm -f "${TMP_PATH}/addons.zip" + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Addons" \ + --progressbox "Updating Addons..." 20 70 + return 0 +} + +############################################################################### +# Update Patches +function updatePatches() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip")" + rm -rf "${PATCH_PATH}" + mkdir -p "${PATCH_PATH}" + echo "Installing new Patches..." + unzip -oq "${TMP_PATH}/patches.zip" -d "${PATCH_PATH}" >/dev/null 2>&1 + if [ -f "${TMP_PATH}/patches.zip" ]; then + rm -f "${TMP_PATH}/patches.zip" + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Patches" \ + --progressbox "Updating Patches..." 20 70 + return 0 +} + +############################################################################### +# Update Modules +function updateModules() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip")" + rm -rf "${MODULES_PATH}" + mkdir -p "${MODULES_PATH}" + echo "Installing new Modules..." + unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1 + if [ -f "${TMP_PATH}/modules.zip" ]; then + rm -f "${TMP_PATH}/modules.zip" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + if [ -n "${PRODUCTVER}" ]; then + PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" + KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" + # Modify KVER for Epyc7002 + if [ "${PLATFORM}" = "epyc7002" ]; then + KVERP="${PRODUCTVER}-${KVER}" + else + KVERP="${KVER}" + fi + fi + # Rebuild modules if model/build is selected + if [ -n "${PLATFORM}" ] && [ -n "${KVERP}" ]; then + writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" + echo "Rebuilding Modules..." + while read -r ID DESC; do + writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" + done <<<$(getAllModules "${PLATFORM}" "${KVERP}") + fi + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Modules" \ + --progressbox "Updating Modules..." 20 70 + return 0 +} + +############################################################################### +# Update Configs +function updateConfigs() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip")" + rm -rf "${MODEL_CONFIG_PATH}" + mkdir -p "${MODEL_CONFIG_PATH}" + echo "Installing new Configs..." + unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" >/dev/null 2>&1 + if [ -f "${TMP_PATH}/configs.zip" ]; then + rm -f "${TMP_PATH}/configs.zip" + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Configs" \ + --progressbox "Updating Configs..." 20 70 + return 0 +} + +############################################################################### +# Update LKMs +function updateLKMs() { + ( + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [ -n "${TAG}" ]; then + echo "New Version: ${TAG}" + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [ -z "${TAG}" ]; then + echo "Error checking new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + else + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms-${TAG}.zip" -o "${TMP_PATH}/rp-lkms.zip")" + rm -rf "${LKM_PATH}" + mkdir -p "${LKM_PATH}" + echo "Installing new LKMs..." + unzip -oq "${TMP_PATH}/rp-lkms.zip" -d "${LKM_PATH}" >/dev/null 2>&1 + if [ -f "${TMP_PATH}/rp-lkms.zip" ]; then + rm -f "${TMP_PATH}/rp-lkms.zip" + else + echo "Error extracting new Version!" + sleep 5 + if [ "${CUSTOM}" = "false" ]; then + return 1 + else + exec reboot + fi + fi + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update LKMs" \ + --progressbox "Updating LKMs..." 20 70 + return 0 +} \ No newline at end of file diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index 39ca6e920..9399addf7 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -8,6 +8,7 @@ . ${ARC_PATH}/include/addons.sh . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/network.sh +. ${ARC_PATH}/include/update.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" @@ -65,246 +66,18 @@ function backtitle() { ############################################################################### # Auto Update Loader function arcUpdate() { - # Update Loader - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Checking latest version..." 0 0 - ACTUALVERSION="${ARC_VERSION}" - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - # Download update file - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}" - rm -f "${TMP_PATH}/update.zip" - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error extracting Updatefile!" 0 0 - sleep 5 - exec reboot - fi - # Process complete update - cp -f "${TMP_PATH}/grub.cfg" "${GRUB_PATH}/grub.cfg" - cp -f "${TMP_PATH}/bzImage-arc" "${ARC_BZIMAGE_FILE}" - cp -f "${TMP_PATH}/initrd-arc" "${ARC_RAMDISK_FILE}" - rm -f "${TMP_PATH}/update.zip" - # Update Addons - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${ADDONS_PATH}" - mkdir -p "${ADDONS_PATH}" - unzip -oq "${TMP_PATH}/addons.zip" -d "${ADDONS_PATH}" >/dev/null 2>&1 - dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ - --infobox "Installing new Addons" 0 0 - for PKG in $(ls ${ADDONS_PATH}/*.addon); do - ADDON=$(basename ${PKG} | sed 's|.addon||') - rm -rf "${ADDONS_PATH}/${ADDON:?}" - mkdir -p "${ADDONS_PATH}/${ADDON}" - tar -xaf "${PKG}" -C "${ADDONS_PATH}/${ADDON}" >/dev/null 2>&1 - rm -f "${ADDONS_PATH}/${ADDON}.addon" - done - rm -f "${TMP_PATH}/addons.zip" - # Update Patches - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${PATCH_PATH}" - mkdir -p "${PATCH_PATH}" - unzip -oq "${TMP_PATH}/patches.zip" -d "${PATCH_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/patches.zip" - # Update Modules - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then - PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" - # Modify KVER for Epyc7002 - if [ "${PLATFORM}" = "epyc7002" ]; then - KVERP="${PRODUCTVER}-${KVER}" - else - KVERP="${KVER}" - fi - fi - rm -rf "${MODULES_PATH}" - mkdir -p "${MODULES_PATH}" - unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1 - # Rebuild modules if model/build is selected - if [[ -n "${PLATFORM}" && -n "${KVERP}" ]]; then - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read -r ID DESC; do - writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "${KVERP}") - fi - rm -f "${TMP_PATH}/modules.zip" - # Update Configs - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${MODEL_CONFIG_PATH}" - mkdir -p "${MODEL_CONFIG_PATH}" - unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/configs.zip" - # Update LKMs - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nRetry..." 0 0 - if [[ $? -ne 0 || -z "${TAG}" ]]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error checking new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms-${TAG}.zip" -o "${TMP_PATH}/rp-lkms.zip") - if [ $? -ne 0 ]; then - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms-${TAG}.zip" -o "${TMP_PATH}/rp-lkms.zip") - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nRetry..." 0 0 - if [ $? -ne 0 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ - --infobox "Error downloading new Version!\nAbort!" 0 0 - sleep 5 - exec reboot - fi - fi - dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ - --infobox "Extracting" 0 0 - rm -rf "${LKM_PATH}" - mkdir -p "${LKM_PATH}" - unzip -oq "${TMP_PATH}/rp-lkms.zip" -d "${LKM_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/rp-lkms.zip" + # Automatic Update + updateLoader + updateAddons + updateConfigs + updateLKMs + updateModules + updatePatches # Ask for Boot dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ --infobox "Update successfull!" 0 0 writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-{PRODUCTVER}-custom" >"${PART3_PATH}/automated" boot } @@ -315,7 +88,7 @@ function boot() { dialog --backtitle "$(backtitle)" --title "Arc Boot" \ --infobox "Rebooting automated Build Mode...\nPlease stay patient!" 4 25 sleep 2 - rebootTo automated + exec reboot } ############################################################################### From b5dedb25f709ca4d2e970b7b27950d419e5b9c71 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 18:29:36 +0200 Subject: [PATCH 02/11] update: fix loop Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/update.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 0173ae2f7..505d39cae 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -2,9 +2,8 @@ . ${ARC_PATH}/include/consts.sh . ${ARC_PATH}/include/configFile.sh -. ${ARC_PATH}/include/addons.sh +. ${ARC_PATH}/include/functions.sh . ${ARC_PATH}/include/modules.sh -. ${ARC_PATH}/include/update.sh CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" @@ -58,6 +57,8 @@ function updateLoader() { fi fi [ -f "${TMP_PATH}/update.zip" ] && rm -f "${TMP_PATH}/update.zip" + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Loader" \ --progressbox "Updating Loader..." 20 70 return 0 @@ -109,6 +110,8 @@ function updateAddons() { exec reboot fi fi + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Addons" \ --progressbox "Updating Addons..." 20 70 return 0 @@ -160,6 +163,8 @@ function updatePatches() { exec reboot fi fi + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Patches" \ --progressbox "Updating Patches..." 20 70 return 0 @@ -230,6 +235,8 @@ function updateModules() { exec reboot fi fi + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Modules" \ --progressbox "Updating Modules..." 20 70 return 0 @@ -281,6 +288,8 @@ function updateConfigs() { exec reboot fi fi + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Configs" \ --progressbox "Updating Configs..." 20 70 return 0 @@ -332,6 +341,8 @@ function updateLKMs() { exec reboot fi fi + echo "Update done!" + sleep 2 ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update LKMs" \ --progressbox "Updating LKMs..." 20 70 return 0 From 94a5d42b75fc1d5e24bba75e87e1f19b42db0798 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 18:32:25 +0200 Subject: [PATCH 03/11] update: rewrite code Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 505d39cae..5d189416c 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -6,6 +6,17 @@ . ${ARC_PATH}/include/modules.sh CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" +PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" +if [ -n "${PRODUCTVER}" ]; then + PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" + KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" + # Modify KVER for Epyc7002 + if [ "${PLATFORM}" = "epyc7002" ]; then + KVERP="${PRODUCTVER}-${KVER}" + else + KVERP="${KVER}" + fi +fi ############################################################################### # Update Loader @@ -207,17 +218,6 @@ function updateModules() { unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1 if [ -f "${TMP_PATH}/modules.zip" ]; then rm -f "${TMP_PATH}/modules.zip" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - if [ -n "${PRODUCTVER}" ]; then - PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" - # Modify KVER for Epyc7002 - if [ "${PLATFORM}" = "epyc7002" ]; then - KVERP="${PRODUCTVER}-${KVER}" - else - KVERP="${KVER}" - fi - fi # Rebuild modules if model/build is selected if [ -n "${PLATFORM}" ] && [ -n "${KVERP}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" From 06d2fd2028e93cd640078bca02c264bfff2b5275 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 18:35:06 +0200 Subject: [PATCH 04/11] update: syntax fix Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 5d189416c..3cf89dffe 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -224,7 +224,7 @@ function updateModules() { echo "Rebuilding Modules..." while read -r ID DESC; do writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "${KVERP}") + done <<<"$(getAllModules "${PLATFORM}" "${KVERP}")" fi else echo "Error extracting new Version!" From b19060ca0659045cc6bdf17b53c6fa7fe0f2f25f Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 19:09:19 +0200 Subject: [PATCH 05/11] update: fix output Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/update.sh | 8 ++++---- files/initrd/opt/arc/update.sh | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 3cf89dffe..dd729cea0 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -158,7 +158,7 @@ function updatePatches() { fi # Download update file echo "Downloading ${TAG}" - STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip")" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip")" rm -rf "${PATCH_PATH}" mkdir -p "${PATCH_PATH}" echo "Installing new Patches..." @@ -211,7 +211,7 @@ function updateModules() { fi # Download update file echo "Downloading ${TAG}" - STATUS="$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip")" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip")" rm -rf "${MODULES_PATH}" mkdir -p "${MODULES_PATH}" echo "Installing new Modules..." @@ -272,7 +272,7 @@ function updateConfigs() { fi # Download update file echo "Downloading ${TAG}" - STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip")" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip")" rm -rf "${MODEL_CONFIG_PATH}" mkdir -p "${MODEL_CONFIG_PATH}" echo "Installing new Configs..." @@ -325,7 +325,7 @@ function updateLKMs() { fi # Download update file echo "Downloading ${TAG}" - STATUS="$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms-${TAG}.zip" -o "${TMP_PATH}/rp-lkms.zip")" + STATUS="$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms-${TAG}.zip" -o "${TMP_PATH}/rp-lkms.zip")" rm -rf "${LKM_PATH}" mkdir -p "${LKM_PATH}" echo "Installing new LKMs..." diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index 9399addf7..fd6921e81 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -78,7 +78,9 @@ function arcUpdate() { --infobox "Update successfull!" 0 0 writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-{PRODUCTVER}-custom" >"${PART3_PATH}/automated" + if [ "${CUSTOM}" = "true" ] && [ ! -f "${PART3_PATH}/automated" ]; then + echo "${ARC_VERSION}-${MODEL}-{PRODUCTVER}-custom" >"${PART3_PATH}/automated" + fi boot } From 93aaf3a7a0d4b21bcbb15cb2b8a332b3e195b539 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 19:20:13 +0200 Subject: [PATCH 06/11] update: fix reboot message Signed-off-by: AuxXxilium --- files/initrd/opt/arc/update.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index fd6921e81..f270e9a7c 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -87,8 +87,13 @@ function arcUpdate() { ############################################################################### # Calls boot.sh to boot into DSM kernel/ramdisk function boot() { - dialog --backtitle "$(backtitle)" --title "Arc Boot" \ - --infobox "Rebooting automated Build Mode...\nPlease stay patient!" 4 25 + if [ "${CUSTOM}" = "true" ]; then + dialog --backtitle "$(backtitle)" --title "Arc Boot" \ + --infobox "Rebooting to automated Build Mode...\nPlease stay patient!" 4 30 + else + dialog --backtitle "$(backtitle)" --title "Arc Boot" \ + --infobox "Rebooting to Config Mode...\nPlease stay patient!" 4 30 + fi sleep 2 exec reboot } From 185381aff6d0ac73a4a38e329e42ae129c81cdb0 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 19:37:04 +0200 Subject: [PATCH 07/11] tree: cleanup and rewrite Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 61 +++++++++++------------ files/initrd/opt/arc/arc.sh | 18 +++---- files/initrd/opt/arc/include/functions.sh | 27 ++-------- 3 files changed, 39 insertions(+), 67 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index f499fadb1..2d9871e0b 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -17,7 +17,7 @@ function editUserConfig() { SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" if [ "${MODEL}" != "${OLDMODEL}" ] || [ "${PRODUCTVER}" != "${OLDPRODUCTVER}" ]; then # Delete old files - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null fi writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" @@ -44,7 +44,7 @@ function addonSelection() { while IFS=': ' read -r KEY VALUE; do [ -n "${KEY}" ] && ADDONS["${KEY}"]="${VALUE}" done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null touch "${TMP_PATH}/opts" while read -r ADDON DESC; do arrayExistItem "${ADDON}" "${!ADDONS[@]}" && ACT="on" || ACT="off" @@ -151,7 +151,7 @@ function modulesMenu() { BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; 5) - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null while read -r ID DESC; do arrayExistItem "${ID}" "${!USERMODULES[@]}" && ACT="on" || ACT="off" echo "${ID} ${DESC} ${ACT}" >>"${TMP_PATH}/opts" @@ -185,8 +185,8 @@ function modulesMenu() { [ $? -ne 0 ] && return TMP_UP_PATH=${TMP_PATH}/users USER_FILE="" - rm -rf ${TMP_UP_PATH} - mkdir -p ${TMP_UP_PATH} + rm -rf "${TMP_UP_PATH}" >/dev/null + mkdir -p "${TMP_UP_PATH}" dialog --backtitle "$(backtitle)" --title "External Modules" \ --ok-label "Proceed" --msgbox "Please upload the *.ko file to /tmp/users.\n- Use SFTP at ${IPCON}:22 User: root PW: arc\n- Use Webclient at http://${IPCON}:7304" 7 50 for F in $(ls "${TMP_UP_PATH}" 2>/dev/null); do @@ -202,7 +202,7 @@ function modulesMenu() { addToModules "${PLATFORM}" "${KVERP}" "${TMP_UP_PATH}/${USER_FILE}" dialog --backtitle "$(backtitle)" --title "External Modules" \ --msgbox "Module: ${USER_FILE}\nadded to ${PLATFORM}-${KVERP}" 7 50 - rm -f "${TMP_UP_PATH}/${USER_FILE}" + rm -f "${TMP_UP_PATH}/${USER_FILE}" >/dev/null else dialog --backtitle "$(backtitle)" --title "External Modules" \ --msgbox "Not a valid file, please try again!" 7 50 @@ -416,7 +416,7 @@ function cmdlineMenu() { --aspect 18 --msgbox "${ITEMS}" 0 0 ;; 8) - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null echo "5 \"Reboot after 5 seconds\"" >>"${TMP_PATH}/opts" echo "0 \"No reboot\"" >>"${TMP_PATH}/opts" echo "-1 \"Restart immediately\"" >>"${TMP_PATH}/opts" @@ -707,7 +707,7 @@ function backupMenu() { fi umount "${TMP_PATH}/mdX" done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Backup Encrytion Key" \ --progressbox "Backup Encryption Key ..." 20 70 if [ "${BACKUPKEY}" = "true" ]; then @@ -781,7 +781,7 @@ function updateMenu() { return 1 fi unzip -oq "${TMP_PATH}/arc-${TAG}.img.zip" -d "${TMP_PATH}" - rm -f "${TMP_PATH}/arc-${TAG}.img.zip" + rm -f "${TMP_PATH}/arc-${TAG}.img.zip" >/dev/null if [ $? -ne 0 ]; then echo "Error extracting Updatefile!" sleep 5 @@ -792,7 +792,7 @@ function updateMenu() { umount "${PART1_PATH}" "${PART2_PATH}" "${PART3_PATH}" dd if="${TMP_PATH}/arc.img" of=$(blkid | grep 'LABEL="ARC3"' | cut -d3 -f1) bs=1M conv=fsync # Ask for Boot - rm -f "${TMP_PATH}/arc.img" + rm -f "${TMP_PATH}/arc.img" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Full-Upgrade Loader" \ --progressbox "Upgrading ..." 20 70 dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ @@ -1403,7 +1403,7 @@ function fullsysinfo() { done fi TEXT+="\nDrives total: ${NUMPORTS}" - [ -f "${TMP_PATH}/diag" ] && rm -f "${TMP_PATH}/diag" + [ -f "${TMP_PATH}/diag" ] && rm -f "${TMP_PATH}/diag" >/dev/null echo -e "${TEXT}" >"${TMP_PATH}/diag" dialog --backtitle "$(backtitle)" --colors --title "Full Sysinfo" \ --extra-button --extra-label "Upload" --no-cancel --textbox "${TMP_PATH}/diag" 0 0 @@ -1584,12 +1584,12 @@ function downgradeMenu() { for I in ${DSMROOTS}; do mount -t ext4 "${I}" "${TMP_PATH}/mdX" [ $? -ne 0 ] && continue - [ -f "${TMP_PATH}/mdX/etc/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc/VERSION" - [ -f "${TMP_PATH}/mdX/etc.defaults/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc.defaults/VERSION" + [ -f "${TMP_PATH}/mdX/etc/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc/VERSION" >/dev/null + [ -f "${TMP_PATH}/mdX/etc.defaults/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc.defaults/VERSION" >/dev/null sync umount "${TMP_PATH}/mdX" done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Allow Downgrade" \ --progressbox "Removing ..." 20 70 dialog --backtitle "$(backtitle)" --title "Allow Downgrade" \ @@ -1606,7 +1606,7 @@ function resetPassword() { --msgbox "No DSM system partition(md0) found!\nPlease insert all disks before continuing." 0 0 return fi - rm -f "${TMP_PATH}/menu" + rm -f "${TMP_PATH}/menu" >/dev/null mkdir -p "${TMP_PATH}/mdX" for I in ${DSMROOTS}; do mount -t ext4 "${I}" "${TMP_PATH}/mdX" @@ -1624,7 +1624,7 @@ function resetPassword() { umount "${TMP_PATH}/mdX" [ -f "${TMP_PATH}/menu" ] && break done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null if [ ! -f "${TMP_PATH}/menu" ]; then dialog --backtitle "$(backtitle)" --title "Reset Password" \ --msgbox "All existing users have been disabled. Please try adding new user." 0 0 @@ -1661,7 +1661,7 @@ function resetPassword() { sync umount "${TMP_PATH}/mdX" done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Reset Password" \ --progressbox "Resetting ..." 20 100 dialog --backtitle "$(backtitle)" --title "Reset Password" \ @@ -1706,7 +1706,7 @@ EOF fi umount "${TMP_PATH}/mdX" done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Add DSM User" \ --progressbox "Adding ..." 20 100 [ "$(cat ${TMP_PATH}/isEnable 2>/dev/null)" = "true" ] && MSG="Add DSM User successful." || MSG="Add DSM User failed." @@ -1739,10 +1739,10 @@ function saveMenu() { RDXZ_PATH="${TMP_PATH}/rdxz_tmp" mkdir -p "${RDXZ_PATH}" (cd "${RDXZ_PATH}"; xz -dc <"${PART3_PATH}/initrd-arc" | cpio -idm) >/dev/null 2>&1 || true - rm -rf "${RDXZ_PATH}/opt/arc" + rm -rf "${RDXZ_PATH}/opt/arc" >/dev/null cp -Rf "$(dirname ${ARC_PATH})" "${RDXZ_PATH}" (cd "${RDXZ_PATH}"; find . 2>/dev/null | cpio -o -H newc -R root:root | xz --check=crc32 >"${PART3_PATH}/initrd-arc") || true - rm -rf "${RDXZ_PATH}" + rm -rf "${RDXZ_PATH}" >/dev/null dialog --backtitle "$(backtitle)" --colors --aspect 18 \ --msgbox "Save to Disk is complete." 0 0 return @@ -1751,7 +1751,7 @@ function saveMenu() { ############################################################################### # let user format disks from inside arc function formatdisks() { - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null while read -r KNAME KMODEL PKNAME TYPE; do [ -z "${KNAME}" ] && continue [ "${KNAME}" = "${LOADER_DISK}" ] || [ "${PKNAME}" = "${LOADER_DISK}" ] || [ "${KMODEL}" = "${LOADER_DISK}" ] && continue @@ -1841,7 +1841,7 @@ EOF fi umount "${TMP_PATH}/mdX" done - rm -rf "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" >/dev/null ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Force enable SSH" \ --progressbox "$(TEXT "Enabling ...")" 20 100 [ "$(cat ${TMP_PATH}/isEnable 2>/dev/null)" = "true" ] && MSG="Enable Telnet&SSH successfully." || MSG="Enable Telnet&SSH failed." @@ -1853,7 +1853,7 @@ EOF ############################################################################### # Clone Loader Disk function cloneLoader() { - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null while read -r KNAME KMODEL PKNAME TYPE; do [ -z "${KNAME}" ] && continue [ -z "${KMODEL}" ] && KMODEL="${TYPE}" @@ -1888,7 +1888,7 @@ function cloneLoader() { [ $? -ne 0 ] && return fi ( - rm -rf "${PART3_PATH}/dl" + rm -rf "${PART3_PATH}/dl" >/dev/null CLEARCACHE=0 gzip -dc "${ARC_PATH}/grub.img.gz" | dd of="${resp}" bs=1M conv=fsync status=progress @@ -1927,10 +1927,10 @@ function cloneLoader() { function resetLoader() { if [ -f "${ORI_ZIMAGE_FILE}" ] || [ -f "${ORI_RDGZ_FILE}" ] || [ -f "${MOD_ZIMAGE_FILE}" ] || [ -f "${MOD_RDGZ_FILE}" ]; then # Clean old files - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null fi - [ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}" - [ -f "${USER_CONFIG_FILE}" ] && rm -f "${USER_CONFIG_FILE}" + [ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}" >/dev/null + [ -f "${USER_CONFIG_FILE}" ] && rm -f "${USER_CONFIG_FILE}" >/dev/null dialog --backtitle "$(backtitle)" --title "Reset Loader" --aspect 18 \ --yesno "Reset successful.\nReboot required!" 0 0 [ $? -ne 0 ] && return @@ -1954,8 +1954,7 @@ function editGrubCfg() { # Grep Logs from dbgutils function greplogs() { if [ -d "${PART1_PATH}/logs" ]; then - rm -f "${TMP_PATH}/log.tar.gz" - rm -f "${PART1_PATH}/log.tar.gz" + rm -f "${PART1_PATH}/log.tar.gz" >/dev/null tar -czf "${PART1_PATH}/log.tar.gz" "${PART1_PATH}/logs" if [ -z "${SSH_TTY}" ]; then # web mv -f "${PART1_PATH}/log.tar.gz" "/var/www/data/log.tar.gz" @@ -1985,7 +1984,7 @@ function greplogs() { # Get DSM Config File from dsmbackup function getbackup() { if [ -d "${PART1_PATH}/dsmbackup" ]; then - rm -f "${TMP_PATH}/dsmconfig.tar.gz" + rm -f "${TMP_PATH}/dsmconfig.tar.gz" >/dev/null tar -czf "${TMP_PATH}/dsmconfig.tar.gz" -C "${PART1_PATH}" dsmbackup if [ -z "${SSH_TTY}" ]; then # web mv -f "${TMP_PATH}/dsmconfig.tar.gz" "/var/www/data/dsmconfig.tar.gz" @@ -2014,7 +2013,7 @@ function getbackup() { ############################################################################### # SataDOM Menu function satadomMenu() { - rm -f "${TMP_PATH}/opts" + rm -f "${TMP_PATH}/opts" >/dev/null echo "0 \"Create SATA node(ARC)\"" >>"${TMP_PATH}/opts" echo "1 \"Native SATA Disk(SYNO)\"" >>"${TMP_PATH}/opts" echo "2 \"Fake SATA DOM(Redpill)\"" >>"${TMP_PATH}/opts" diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 8989fe412..e514f26ca 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -265,7 +265,7 @@ function arcModel() { BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then # Delete old files - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null fi fi arcVersion @@ -294,7 +294,7 @@ function arcVersion() { writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}" if [ -f "${ORI_ZIMAGE_FILE}" ] || [ -f "${ORI_RDGZ_FILE}" ] || [ -f "${MOD_ZIMAGE_FILE}" ] || [ -f "${MOD_RDGZ_FILE}" ]; then # Delete old files - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null fi fi PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" @@ -622,9 +622,7 @@ function make() { DT="$(readConfigKey "platforms.${PLATFORM}.dt" "${P_FILE}")" CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" # Cleanup - if [ -d "${UNTAR_PAT_PATH}" ]; then - rm -rf "${UNTAR_PAT_PATH}" - fi + [ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}" >/dev/null mkdir -p "${UNTAR_PAT_PATH}" if [ "${OFFLINE}" = "false" ]; then # Get PAT Data from Config @@ -787,7 +785,7 @@ function make() { if copyDSMFiles "${UNTAR_PAT_PATH}"; then dialog --backtitle "$(backtitle)" --title "DSM Copy" --aspect 18 \ --infobox "DSM Copy successful!" 0 0 - rm -rf "${UNTAR_PAT_PATH}" + rm -rf "${UNTAR_PAT_PATH}" >/dev/null else dialog --backtitle "$(backtitle)" --title "DSM Copy" --aspect 18 \ --infobox "DSM Copy failed!\nExit." 0 0 @@ -816,7 +814,7 @@ function arcFinish() { if grep -q "automated_arc" /proc/cmdline; then # Check for Custom Build if [ "${CUSTOM}" = "false" ]; then - [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" + [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null fi boot && exit 0 else @@ -1040,7 +1038,7 @@ else if [ "${CUSTOM}" = "true" ]; then [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-{PRODUCTVER}-custom" >"${PART3_PATH}/automated" elif [ "${CUSTOM}" = "false" ]; then - [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" + [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null fi NEXT="R" ;; @@ -1173,10 +1171,6 @@ else # Loader Settings x) backupMenu; NEXT="x" ;; 9) [ "${OFFLINE}" = "true" ] && OFFLINE='false' || OFFLINE='true' - [ -f "${ORI_ZIMAGE_FILE}" ] && rm -f "${ORI_ZIMAGE_FILE}" - [ -f "${ORI_RDGZ_FILE}" ] && rm -f "${ORI_RDGZ_FILE}" - [ -f "${MOD_ZIMAGE_FILE}" ] && rm -f "${MOD_ZIMAGE_FILE}" - [ -f "${MOD_RDGZ_FILE}" ] && rm -f "${MOD_RDGZ_FILE}" writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index 142c753ff..1a643d301 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -4,6 +4,7 @@ . ${ARC_PATH}/include/consts.sh . ${ARC_PATH}/include/configFile.sh . ${ARC_PATH}/include/addons.sh +. ${ARC_PATH}/include/update.sh ############################################################################### # Just show error message and dies @@ -368,31 +369,9 @@ function livepatch() { # Looking for Update if [ ${FAIL} -eq 1 ]; then # Update Configs - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - return 1 - fi - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip") - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - return 1 - fi - rm -rf "${MODEL_CONFIG_PATH}" - mkdir -p "${MODEL_CONFIG_PATH}" - unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/configs.zip" + updateConfigs # Update Patches - TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" - if [[ $? -ne 0 || -z "${TAG}" ]]; then - return 1 - fi - STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip") - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - return 1 - fi - rm -rf "${PATCH_PATH}" - mkdir -p "${PATCH_PATH}" - unzip -oq "${TMP_PATH}/patches.zip" -d "${PATCH_PATH}" >/dev/null 2>&1 - rm -f "${TMP_PATH}/patches.zip" + updatePatches # Patch zImage if ! ${ARC_PATH}/zimage-patch.sh; then FAIL=1 From d50c968a95839e8381d0d5e5ba3dcfef6f7d44e5 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 19:57:48 +0200 Subject: [PATCH 08/11] tree: cleanup Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 3 ++ files/initrd/opt/arc/arc.sh | 1 - files/initrd/opt/arc/include/functions.sh | 56 -------------------- files/initrd/opt/arc/include/update.sh | 62 +++++++++++++++++++++-- files/initrd/opt/arc/update.sh | 1 - 5 files changed, 60 insertions(+), 63 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 2d9871e0b..1001a7d2f 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1,3 +1,6 @@ + +[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + ############################################################################### # Permits user edit the user config function editUserConfig() { diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index e514f26ca..9741ebc4d 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -9,7 +9,6 @@ . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/storage.sh . ${ARC_PATH}/include/network.sh -. ${ARC_PATH}/include/update.sh . ${ARC_PATH}/arc-functions.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index 1a643d301..cfc327b78 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -344,62 +344,6 @@ function convert_netmask() { echo "${bits}" } -############################################################################### -# Livepatch -function livepatch() { - FAIL=0 - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" - if [ "${OFFLINE}" = "false" ]; then - # Looking for Update - if [ ${FAIL} -eq 1 ]; then - # Update Configs - updateConfigs - # Update Patches - updatePatches - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - fi - fi - if [ ${FAIL} -eq 1 ]; then - echo - echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 - sleep 5 - exit 1 - else - echo "DSM Image patched - Ready!" - fi -} - ############################################################################### # Rebooting # (based on pocopico's TCRP code) diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index dd729cea0..f7f0afc35 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -1,9 +1,5 @@ -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -. ${ARC_PATH}/include/consts.sh -. ${ARC_PATH}/include/configFile.sh -. ${ARC_PATH}/include/functions.sh -. ${ARC_PATH}/include/modules.sh +[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" @@ -346,4 +342,60 @@ function updateLKMs() { ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update LKMs" \ --progressbox "Updating LKMs..." 20 70 return 0 +} + +############################################################################### +# Livepatch +function livepatch() { + FAIL=0 + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" + if [ "${OFFLINE}" = "false" ]; then + # Looking for Update + if [ ${FAIL} -eq 1 ]; then + # Update Configs + updateConfigs + # Update Patches + updatePatches + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + fi + fi + if [ ${FAIL} -eq 1 ]; then + echo + echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 + sleep 5 + exit 1 + else + echo "DSM Image patched - Ready!" + fi } \ No newline at end of file diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index f270e9a7c..88599ee2b 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -8,7 +8,6 @@ . ${ARC_PATH}/include/addons.sh . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/network.sh -. ${ARC_PATH}/include/update.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" From 2fc01c19df9c257a764291fe34a39a396068951e Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 20:08:22 +0200 Subject: [PATCH 09/11] tree: rewrite filelinks Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 2 -- files/initrd/opt/arc/arc.sh | 1 + files/initrd/opt/arc/boot.sh | 1 + files/initrd/opt/arc/include/functions.sh | 1 - files/initrd/opt/arc/include/update.sh | 32 ++++++++++++----------- files/initrd/opt/arc/update.sh | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 1001a7d2f..427e15b4d 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1,6 +1,4 @@ -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - ############################################################################### # Permits user edit the user config function editUserConfig() { diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 9741ebc4d..e514f26ca 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -9,6 +9,7 @@ . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/storage.sh . ${ARC_PATH}/include/network.sh +. ${ARC_PATH}/include/update.sh . ${ARC_PATH}/arc-functions.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 15c1abd3f..6d5feb6d1 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -4,6 +4,7 @@ set -e [[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" . ${ARC_PATH}/include/functions.sh +. ${ARC_PATH}/include/update.sh # Get Loader Disk Bus BUS=$(getBus "${LOADER_DISK}") diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index cfc327b78..f721f6211 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -4,7 +4,6 @@ . ${ARC_PATH}/include/consts.sh . ${ARC_PATH}/include/configFile.sh . ${ARC_PATH}/include/addons.sh -. ${ARC_PATH}/include/update.sh ############################################################################### # Just show error message and dies diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index f7f0afc35..7d889a478 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -1,23 +1,9 @@ -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - -CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -if [ -n "${PRODUCTVER}" ]; then - PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" - # Modify KVER for Epyc7002 - if [ "${PLATFORM}" = "epyc7002" ]; then - KVERP="${PRODUCTVER}-${KVER}" - else - KVERP="${KVER}" - fi -fi - ############################################################################### # Update Loader function updateLoader() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 @@ -75,6 +61,7 @@ function updateLoader() { # Update Addons function updateAddons() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 @@ -128,6 +115,7 @@ function updateAddons() { # Update Patches function updatePatches() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 @@ -181,6 +169,7 @@ function updatePatches() { # Update Modules function updateModules() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 @@ -215,6 +204,17 @@ function updateModules() { if [ -f "${TMP_PATH}/modules.zip" ]; then rm -f "${TMP_PATH}/modules.zip" # Rebuild modules if model/build is selected + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + if [ -n "${PRODUCTVER}" ]; then + PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" + KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" + # Modify KVER for Epyc7002 + if [ "${PLATFORM}" = "epyc7002" ]; then + KVERP="${PRODUCTVER}-${KVER}" + else + KVERP="${KVER}" + fi + fi if [ -n "${PLATFORM}" ] && [ -n "${KVERP}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" echo "Rebuilding Modules..." @@ -242,6 +242,7 @@ function updateModules() { # Update Configs function updateConfigs() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 @@ -295,6 +296,7 @@ function updateConfigs() { # Update LKMs function updateLKMs() { ( + CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index 88599ee2b..9437d3b49 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -5,9 +5,9 @@ [[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" . ${ARC_PATH}/include/functions.sh -. ${ARC_PATH}/include/addons.sh . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/network.sh +. ${ARC_PATH}/include/update.sh [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" From c2beb031423b7627102f0d695ac4676e0b38ca87 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 20:35:05 +0200 Subject: [PATCH 10/11] tree: more fixes Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/functions.sh | 56 +++++++++++++++++++++++ files/initrd/opt/arc/include/update.sh | 56 ----------------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index f721f6211..180b8af70 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -413,4 +413,60 @@ function extractDSMFiles() { else return 1 fi +} + +############################################################################### +# Livepatch +function livepatch() { + FAIL=0 + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" + if [ "${OFFLINE}" = "false" ]; then + # Looking for Update + if [ ${FAIL} -eq 1 ]; then + # Update Configs + updateConfigs + # Update Patches + updatePatches + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + fi + fi + if [ ${FAIL} -eq 1 ]; then + echo + echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 + sleep 5 + exit 1 + else + echo "DSM Image patched - Ready!" + fi } \ 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 7d889a478..e0125d607 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -344,60 +344,4 @@ function updateLKMs() { ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update LKMs" \ --progressbox "Updating LKMs..." 20 70 return 0 -} - -############################################################################### -# Livepatch -function livepatch() { - FAIL=0 - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" - if [ "${OFFLINE}" = "false" ]; then - # Looking for Update - if [ ${FAIL} -eq 1 ]; then - # Update Configs - updateConfigs - # Update Patches - updatePatches - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - fi - fi - if [ ${FAIL} -eq 1 ]; then - echo - echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 - sleep 5 - exit 1 - else - echo "DSM Image patched - Ready!" - fi } \ No newline at end of file From d51add1678f3272b55b450e67af8912c0b216569 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Wed, 22 May 2024 20:40:37 +0200 Subject: [PATCH 11/11] functions: cleanup code Signed-off-by: AuxXxilium --- files/initrd/opt/arc/include/functions.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index 180b8af70..ee196057b 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -423,16 +423,12 @@ function livepatch() { if ! ${ARC_PATH}/zimage-patch.sh; then FAIL=1 else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" FAIL=0 fi # Patch Ramdisk if ! ${ARC_PATH}/ramdisk-patch.sh; then FAIL=1 else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" FAIL=0 fi OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" @@ -447,16 +443,12 @@ function livepatch() { if ! ${ARC_PATH}/zimage-patch.sh; then FAIL=1 else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" FAIL=0 fi # Patch Ramdisk if ! ${ARC_PATH}/ramdisk-patch.sh; then FAIL=1 else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" FAIL=0 fi fi @@ -467,6 +459,10 @@ function livepatch() { sleep 5 exit 1 else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" echo "DSM Image patched - Ready!" fi } \ No newline at end of file