From e339aad9e22db65e39a9087fcfe5a5b7d91e37df Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 30 Aug 2024 19:34:10 +0200 Subject: [PATCH 1/5] arc: fix logic Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 43dae0c9b..2586544e2 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -304,9 +304,6 @@ function arcVersion() { PAT_URL="" PAT_HASH="" URLVER="" - # Cleanup - [ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}" - mkdir -p "${UNTAR_PAT_PATH}" while true; do PJ="$(python ${ARC_PATH}/include/functions.py getpats4mv -m "${MODEL}" -v "${PRODUCTVER}")" if [[ -z "${PJ}" || "${PJ}" = "{}" ]]; then @@ -355,8 +352,7 @@ function arcVersion() { if [ "${OFFLINE}" == "false" ]; then dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ --infobox "Check PAT Data..." 3 40 - URLCHECK="$(curl --head -skL -m 10 "${PAT_URL}" | head -n 1)" - if echo "${URLCHECK}" | grep -q 404; then + if curl --head -skL -m 10 "${PAT_URL}" | head -n 1 | grep -q 404; then VALID="false" else VALID="true" @@ -433,6 +429,9 @@ function arcVersion() { sleep 5 fi fi + # Cleanup + [ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}" + mkdir -p "${UNTAR_PAT_PATH}" if [ -f "${DSM_FILE}" ] && [ "${VALID}" == "true" ]; then tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" 2>/dev/null VALID="true" From 60f9bcf768452ec15da249e417fe2f69e8410565 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 30 Aug 2024 19:58:32 +0200 Subject: [PATCH 2/5] tree: rework more logic Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 5 +++-- files/initrd/opt/arc/init.sh | 2 +- files/initrd/opt/arc/update.sh | 9 ++++----- files/p1/boot/grub/grub.cfg | 22 +++++++++++----------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 2586544e2..31ced3999 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -326,7 +326,7 @@ function arcVersion() { URLVER="$(echo "${PV}" | cut -d'.' -f1,2)" [ "${PRODUCTVER}" != "${URLVER}" ] && PRODUCTVER="${URLVER}" writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}" - [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && break + [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && VALID="true" && break fi done if [ -z "${PAT_URL}" ] || [ -z "${PAT_HASH}" ]; then @@ -341,8 +341,8 @@ function arcVersion() { return 1 # 1 or 255 # cancel-button or ESC PAT_URL="$(cat "${TMP_PATH}/resp" | sed -n '1p')" PAT_HASH="$(cat "${TMP_PATH}/resp" | sed -n '2p')" + [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && VALID="true" fi - VALID="true" elif [ "${AUTOMATED}" == "true" ]; then PAT_URL="$(readConfigKey "paturl" "${USER_CONFIG_FILE}")" PAT_HASH="$(readConfigKey "pathash" "${USER_CONFIG_FILE}")" @@ -359,6 +359,7 @@ function arcVersion() { fi fi sleep 2 + mkdir -p "${USER_UP_PATH}" DSM_FILE="${USER_UP_PATH}/${PAT_HASH}.tar" if [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "false" ] && [ "${VALID}" == "true" ]; then dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index ecbb1f532..750f0bf06 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -84,11 +84,11 @@ if grep -q "automated_arc" /proc/cmdline; then else writeConfigKey "automated" "false" "${USER_CONFIG_FILE}" fi +[ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null 2>&1 || true if [ -f "${PART1_PATH}/ARC-BRANCH" ]; then ARCBRANCH=$(cat "${PART1_PATH}/ARC-BRANCH") && writeConfigKey "arc.branch" "${ARCBRANCH}" "${USER_CONFIG_FILE}" rm -f "${PART1_PATH}/ARC-BRANCH" >/dev/null 2>&1 || true fi -[ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null 2>&1 || true # Check for compatibility compatboot diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index 99fcaf832..2fb7aa648 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -32,6 +32,7 @@ fi # Get Config Status CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" +BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" # Get Keymap and Timezone Config ntpCheck @@ -65,19 +66,17 @@ function arcUpdate() { # Ask for Boot dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ --infobox "Update successful!" 0 0 - if [ "${CONFDONE}" == "true" ] && [ ! -f "${PART3_PATH}/automated" ]; then - echo "${ARC_VERSION}-${MODEL}-${PRODUCTVER}-custom" >"${PART3_PATH}/automated" - fi boot } ############################################################################### # Calls boot.sh to boot into DSM kernel/ramdisk function boot() { - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - if [ "${CONFDONE}" == "true" ]; then + BUILDDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" + if [ "${BUILDDONE}" == "true" ]; then dialog --backtitle "$(backtitle)" --title "Arc Boot" \ --infobox "Rebooting to automated Build Mode...\nPlease stay patient!" 4 30 + [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-${PRODUCTVER}" >"${PART3_PATH}/automated" sleep 3 rebootTo automated else diff --git a/files/p1/boot/grub/grub.cfg b/files/p1/boot/grub/grub.cfg index 4dcb50293..5da3e2da6 100644 --- a/files/p1/boot/grub/grub.cfg +++ b/files/p1/boot/grub/grub.cfg @@ -86,17 +86,6 @@ set color_normal=white/black set ARC_CMDLINE="earlyprintk earlycon=uart8250,io,0x3f8,115200n8 console=ttyS0,115200n8 root=/dev/ram rootwait net.ifnames=0 panic=0 pcie_aspm=off" search --set=root --label "ARC3" -if [ -e /automated ]; then - menuentry 'Arc Automated Mode' --id automated { - set_gfxpayload - echo "Loading Arc Kernel..." - linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} automated_arc - echo "Loading Arc Initramfs..." - initrd /initrd-arc - echo "Booting..." - } -fi - if [ -s /zImage-dsm -a -s /initrd-dsm ]; then if [ "${default}" = "direct" ]; then set timeout="1" @@ -120,6 +109,17 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then } fi +if [ -e /automated ]; then + menuentry 'Arc Automated Mode' --id automated { + set_gfxpayload + echo "Loading Arc Kernel..." + linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} automated_arc + echo "Loading Arc Initramfs..." + initrd /initrd-arc + echo "Booting..." + } +fi + menuentry 'Arc Config Mode' --id config { set_gfxpayload echo "Loading Arc Kernel..." From 0526fc732a8bafe542155c22d8ea4876d14465ef Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 30 Aug 2024 22:15:01 +0200 Subject: [PATCH 3/5] arc: add url sanity check Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 31ced3999..84aa5c900 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -314,9 +314,20 @@ function arcVersion() { [ $? -eq 0 ] && continue # yes-button return 1 else - PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join(" ")')" + PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join("\n")')" + touch "${TMP_PATH}/versions" + while IFS= read -r line; do + VERSION="${line}" + CHECK_URL=$(echo "${PJ}" | jq -r ".\"${VERSION}\".url") + if curl --head -skL -m 5 "${CHECK_URL}" | head -n 1 | grep -q "404\|403"; then + continue + else + echo "${VERSION}" >>"${TMP_PATH}/versions" + fi + done < <(echo "${PVS}") + DSMPVS="$(cat ${TMP_PATH}/versions)" dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ - --no-items --menu "Choose a DSM Build" 0 0 0 ${PVS} \ + --no-items --menu "Choose a DSM Build" 0 0 0 ${DSMPVS} \ 2>${TMP_PATH}/resp RET=$? [ ${RET} -ne 0 ] && return From 8d3479a5244bb3f9203cd920c7d02c88d97770d4 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 31 Aug 2024 09:35:40 +0200 Subject: [PATCH 4/5] arc: fix more logic Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 20 ++++++---------- files/initrd/opt/arc/include/update.sh | 32 +++++++++++++------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 84aa5c900..600159782 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -217,7 +217,6 @@ function arcModel() { writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" - CHANGED="true" elif [ "${MODEL}" != "${resp}" ]; then PRODUCTVER="" MODEL="${resp}" @@ -241,11 +240,6 @@ function arcModel() { writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}" writeConfigKey "sn" "" "${USER_CONFIG_FILE}" writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" - CHANGED="true" - fi - if [ "${CHANGED}" == "true" ]; then - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true - rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true fi # Read Platform Data ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" @@ -293,11 +287,6 @@ function arcVersion() { writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - CHANGED="true" - fi - if [ "${CHANGED}" == "true" ]; then - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true - rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true fi dialog --backtitle "$(backtitle)" --title "DSM Version" \ --infobox "Reading DSM Build..." 3 25 @@ -315,7 +304,7 @@ function arcVersion() { return 1 else PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join("\n")')" - touch "${TMP_PATH}/versions" + [ -f "${TMP_PATH}/versions" ] && rm -f "${TMP_PATH}/versions" && touch "${TMP_PATH}/versions" while IFS= read -r line; do VERSION="${line}" CHECK_URL=$(echo "${PJ}" | jq -r ".\"${VERSION}\".url") @@ -370,12 +359,17 @@ function arcVersion() { fi fi sleep 2 + # Cleanup + if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ "${PAT_URL}" != "${PAT_URL_CONF}" ]; then + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true + rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true + fi mkdir -p "${USER_UP_PATH}" DSM_FILE="${USER_UP_PATH}/${PAT_HASH}.tar" if [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "false" ] && [ "${VALID}" == "true" ]; then dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ --infobox "Try to get DSM Image..." 3 40 - if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ "${PAT_URL}" != "${PAT_URL_CONF}" ] || [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then + if [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then # Write new PAT Data to Config writeConfigKey "paturl" "${PAT_URL}" "${USER_CONFIG_FILE}" writeConfigKey "pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}" diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index d2e1baa07..9f7a9dc2c 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -52,13 +52,13 @@ function upgradeLoader () { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/arc.img.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/arc.img.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done fi @@ -155,14 +155,14 @@ function updateLoader() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" @@ -220,14 +220,14 @@ function updateAddons() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/addons.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/addons.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" @@ -291,14 +291,14 @@ function updatePatches() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/patches.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/patches.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" @@ -354,14 +354,14 @@ function updateCustom() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/custom.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/custom.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" @@ -417,14 +417,14 @@ function updateModules() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/modules.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/modules.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256" @@ -495,13 +495,13 @@ function updateConfigs() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/configs.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/configs.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done fi @@ -557,13 +557,13 @@ function updateLKMs() { if [ "${ARCNIC}" == "auto" ]; then curl -#kL "${URL}" -o "${TMP_PATH}/rp-lkms.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done else curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/rp-lkms.zip" 2>&1 | while IFS= read -r -n1 char; do [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ; [[ $keep == 1 ]] && progress="$progress$char" ; done fi From e9819fee80541b076073650959173abd3bed72da Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 31 Aug 2024 09:38:20 +0200 Subject: [PATCH 5/5] arc: cleanup old files Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 600159782..094dcfde5 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -304,7 +304,7 @@ function arcVersion() { return 1 else PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join("\n")')" - [ -f "${TMP_PATH}/versions" ] && rm -f "${TMP_PATH}/versions" && touch "${TMP_PATH}/versions" + [ -f "${TMP_PATH}/versions" ] && rm -f "${TMP_PATH}/versions" >/dev/null 2>&1 && touch "${TMP_PATH}/versions" while IFS= read -r line; do VERSION="${line}" CHECK_URL=$(echo "${PJ}" | jq -r ".\"${VERSION}\".url") @@ -360,12 +360,13 @@ function arcVersion() { fi sleep 2 # Cleanup + mkdir -p "${USER_UP_PATH}" + DSM_FILE="${USER_UP_PATH}/${PAT_HASH}.tar" if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ "${PAT_URL}" != "${PAT_URL_CONF}" ]; then - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true + rm -f "${USER_UP_PATH}/${PAT_HASH_CONF}.tar" >/dev/null 2>&1 || true fi - mkdir -p "${USER_UP_PATH}" - DSM_FILE="${USER_UP_PATH}/${PAT_HASH}.tar" if [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "false" ] && [ "${VALID}" == "true" ]; then dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \ --infobox "Try to get DSM Image..." 3 40 @@ -400,7 +401,7 @@ function arcVersion() { elif [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "true" ] && [ "${AUTOMATED}" == "false" ]; then PAT_FILE=$(ls ${USER_UP_PATH}/*.pat | head -n 1) if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ]; then - rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true + rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true VALID="true" elif [ ! -f "${PAT_FILE}" ]; then # Check for existing Files @@ -827,7 +828,7 @@ function make() { ############################################################################### # Finish Building Loader function arcFinish() { - rm -f "${LOG_FILE}" >/dev/null + rm -f "${LOG_FILE}" >/dev/null 2>&1 || true writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" if [ "${AUTOMATED}" == "true" ]; then