From 50bee6f3c73e41ec218a5da73f36f7306865fd6a Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Mon, 1 Jul 2024 19:26:51 +0200 Subject: [PATCH] arc: rework Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 137 +++++++++++-------------- files/initrd/opt/arc/arc.sh | 103 +++++++++++-------- files/initrd/opt/arc/include/update.sh | 108 ++++++++++++++----- files/initrd/opt/arc/update.sh | 4 +- 4 files changed, 208 insertions(+), 144 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 7eac86be..5b124887 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -737,6 +737,8 @@ function backupMenu() { 2>"${TMP_PATH}/resp" resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 + # Check for compatibility + compatboot if [ ${resp} -eq 1 ]; then arcSummary elif [ ${resp} -eq 2 ]; then @@ -815,20 +817,23 @@ function updateMenu() { while true; do dialog --backtitle "$(backtitle)" --cancel-label "Exit" \ --menu "Choose an Option" 0 0 0 \ - 1 "Full-Upgrade Loader" \ - 2 "Update Addons" \ - 3 "Update Configs" \ - 4 "Update LKMs" \ - 5 "Update Modules" \ - 6 "Update Patches" \ - 7 "Automated Update Mode" \ + 1 "Automated Update Mode" \ + 2 "Full-Upgrade Loader (reflash)" \ + 3 "Update Loader" \ + 4 "Update Addons" \ + 5 "Update Configs" \ + 6 "Update LKMs" \ + 7 "Update Modules" \ + 8 "Update Patches" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && break case "$(cat ${TMP_PATH}/resp)" in 1) - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --infobox "Checking latest version..." 0 0 - ACTUALVERSION="${ARC_VERSION}" + dialog --backtitle "$(backtitle)" --title "Automated Update" --aspect 18 \ + --msgbox "Loader will proceed Automated Update Mode.\nPlease wait until progress is finished!" 0 0 + . ${ARC_PATH}/update.sh + ;; + 2) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Upgrade Loader" \ @@ -836,19 +841,11 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" + [ $? -ne 0 ] && continue opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - if [ "${ARCNIC}" == "auto" ]; then - TAG="$(curl -m 5 -w "%{http_code}" -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - else - TAG="$(curl --interface ${ARCNIC} -m 5 -w "%{http_code}" -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - fi - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ] || [ -z "${TAG}" ]; then - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --msgbox "Error checking new Version!" 0 0 - return 1 - fi + TAG="" elif [ ${opts} -eq 2 ]; then dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ --inputbox "Type the Version!" 0 0 \ @@ -856,50 +853,36 @@ function updateMenu() { TAG=$(cat "${TMP_PATH}/input") [ -z "${TAG}" ] && return 1 fi - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --infobox "Downloading ${TAG}" 0 0 - if [ "${ACTUALVERSION}" == "${TAG}" ]; then - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --yesno "No new version. Actual version is ${ACTUALVERSION}\nForce update?" 0 0 - [ $? -ne 0 ] && return 1 - fi - ( # Download update file - if [ "${ARCNIC}" == "auto" ]; then - curl -#kL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip" 2>&1 | while IFS= read -r -n1 char; do - [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; - [[ $keep == 1 ]] && progress="$progress$char" ; - done - else - curl --interface ${ARCNIC} -#kL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip" 2>&1 | while IFS= read -r -n1 char; do - [[ $char =~ [0-9] ]] && keep=1 ; - [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; - [[ $keep == 1 ]] && progress="$progress$char" ; - done - fi - if [ -f "${TMP_PATH}/arc-${TAG}.img.zip" ]; then - echo "Downloading Updatefile successful!" - else - echo "Error downloading Updatefile!" - sleep 5 - return 1 - fi - unzip -oq "${TMP_PATH}/arc-${TAG}.img.zip" -d "${TMP_PATH}" - rm -f "${TMP_PATH}/arc-${TAG}.img.zip" >/dev/null - echo "Installing new Loader Image..." - # Process complete update - 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" >/dev/null - ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Full-Upgrade Loader" \ - --progressbox "Upgrading ..." 20 70 - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --yesno "Arc Upgrade successful. New Version: ${TAG}\nUse Recover from DSM to get your old Config.\nReboot?" 0 0 - [ $? -ne 0 ] && return 1 + upgradeLoader "${TAG}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" exec reboot && exit 0 ;; - 2) + 3) + # Ask for Tag + TAG="" + dialog --clear --backtitle "$(backtitle)" --title "Update Loader" \ + --menu "Which Version?" 0 0 0 \ + 1 "Latest" \ + 2 "Select Version" \ + 2>"${TMP_PATH}/opts" + [ $? -ne 0 ] && continue + opts=$(cat ${TMP_PATH}/opts) + [ -z "${opts}" ] && return 1 + if [ ${opts} -eq 1 ]; then + TAG="" + elif [ ${opts} -eq 2 ]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" \ + --inputbox "Type the Version!" 0 0 \ + 2>"${TMP_PATH}/input" + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 + fi + updateLoader "${TAG}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + ;; + 4) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Update Addons" \ @@ -923,7 +906,7 @@ function updateMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; - 3) + 5) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Update Configs" \ @@ -948,7 +931,7 @@ function updateMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; - 4) + 6) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Update LKMs" \ @@ -971,7 +954,7 @@ function updateMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; - 5) + 7) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Update Modules" \ @@ -994,7 +977,7 @@ function updateMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; - 6) + 8) # Ask for Tag TAG="" dialog --clear --backtitle "$(backtitle)" --title "Update Patches" \ @@ -1017,11 +1000,6 @@ function updateMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; - 7) - dialog --backtitle "$(backtitle)" --title "Automated Update" --aspect 18 \ - --msgbox "Loader will proceed Automated Update Mode.\nPlease wait until progress is finished!" 0 0 - . ${ARC_PATH}/update.sh - ;; esac done return @@ -2078,7 +2056,7 @@ function governorMenu () { function governorSelection () { rm -f "${TMP_PATH}/opts" >/dev/null touch "${TMP_PATH}/opts" - if [ "${CPUFREQ}" == "true" ]; then + if [ "${CUSTOM}" == "false" ]; then # Selectable CPU governors [ "${PLATFORM}" == "epyc7002" ] && echo -e "schedutil \"use schedutil to scale frequency *\"" >>"${TMP_PATH}/opts" [ "${PLATFORM}" != "epyc7002" ] && echo -e "ondemand \"use ondemand to scale frequency *\"" >>"${TMP_PATH}/opts" @@ -2086,17 +2064,26 @@ function governorSelection () { echo -e "performance \"always run at max frequency\"" >>"${TMP_PATH}/opts" echo -e "powersave \"always run at lowest frequency\"" >>"${TMP_PATH}/opts" echo -e "userspace \"use userspace settings to scale frequency\"" >>"${TMP_PATH}/opts" - dialog --backtitle "$(backtitle)" --title "DSM Frequency Scaling" \ + dialog --backtitle "$(backtitle)" --title "CPU Frequency Scaling" \ --menu "Choose a Governor\n* Recommended Option" 0 0 0 --file "${TMP_PATH}/opts" \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && return resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return CPUGOVERNOR=${resp} - writeConfigKey "arc.governor" "${CPUGOVERNOR}" "${USER_CONFIG_FILE}" else - dialog --backtitle "$(backtitle)" --title "DSM Frequency Scaling" \ + [ "${PLATFORM}" == "epyc7002" ] && CPUGOVERNOR="schedutil" + [ "${PLATFORM}" != "epyc7002" ] && CPUGOVERNOR="ondemand" + fi + writeConfigKey "arc.governor" "${CPUGOVERNOR}" "${USER_CONFIG_FILE}" +else + if [ "${CUSTOM}" == "false" ]; then + dialog --backtitle "$(backtitle)" --title "CPU Frequency Scaling" \ --msgbox "CPU frequency scaling not supported!" 0 0 + else + dialog --backtitle "$(backtitle)" --title "CPU Frequency Scaling" \ + --infobox "CPU frequency scaling not supported!" 0 0 + sleep 5 fi } diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 3b3da31f..6628f355 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -6,6 +6,7 @@ . ${ARC_PATH}/include/functions.sh . ${ARC_PATH}/include/addons.sh +. ${ARC_PATH}/include/compat.sh . ${ARC_PATH}/include/modules.sh . ${ARC_PATH}/include/storage.sh . ${ARC_PATH}/include/network.sh @@ -209,32 +210,42 @@ function arcModel() { if [ "${CUSTOM}" == "false" ]; then PRODUCTVER="" MODEL="${resp}" + PLATFORM="$(grep -w "${MODEL}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" + MODELID=$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/') writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" writeConfigKey "productver" "" "${USER_CONFIG_FILE}" + writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" + writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.emmcboot" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.hddsort" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" + writeConfigKey "arc.odp" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" + writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" + writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" + writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" + writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" else MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PLATFORM="$(grep -w "${MODEL}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" + MODELID=$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/') + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" + writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" + writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" + writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" + writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" fi - PLATFORM="$(grep -w "${MODEL}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" - MODELID=$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/') - writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.emmcboot" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.hddsort" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" - writeConfigKey "arc.odp" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" - writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" - writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" - writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" - writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" - writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" @@ -296,7 +307,6 @@ function arcVersion() { else KVERP="${KVER}" fi - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" # Rewrite modules writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" cp -f "${ARC_PATH}/include/modulelist" "${USER_UP_PATH}/modulelist" @@ -333,10 +343,11 @@ function arcPatch() { CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)" # Check for Custom Build - if [ "${CUSTOM}" == "true" ]; then + SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" + if [ "${CUSTOM}" == "true" ] && [ -z "${SN}" ]; then SN=$(generateSerial "${MODEL}" false) writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - else + elif [ "${CUSTOM}" == "false" ]; then if [ -n "${ARCCONF}" ]; then dialog --clear --backtitle "$(backtitle)" \ --nocancel --title "Arc Patch"\ @@ -438,14 +449,15 @@ function arcSettings() { sleep 2 getmapSelection fi + # Check for CPU Frequency Scaling + if [ "${CPUFREQ}" == "true" ]; then + # Select Governor for DSM + dialog --backtitle "$(backtitle)" --colors --title "CPU Frequency Scaling" \ + --infobox "Generating Governor Table..." 3 40 + governorSelection + fi # Check for Custom Build if [ "${CUSTOM}" == "false" ]; then - if [ "${CPUFREQ}" == "true" ]; then - # Select Governor for DSM - dialog --backtitle "$(backtitle)" --colors --title "DSM Frequency Scaling" \ - --infobox "Generating Governor Table..." 3 40 - governorSelection - fi # Select Addons dialog --backtitle "$(backtitle)" --colors --title "DSM Addons" \ --infobox "Loading Addons Table..." 3 40 @@ -714,7 +726,7 @@ function make() { fi fi fi - elif [ "${OFFLINE}" == "true" ]; then + elif [ "${OFFLINE}" == "true" ] && [ "${CUSTOM}" == "false" ]; then if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ]; then rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true VALID="true" @@ -754,13 +766,20 @@ function make() { sleep 5 fi fi + else + dialog --backtitle "$(backtitle)" --title "Arc Build" --aspect 18 \ + --infobox "Can't build Custom Loader while Offline!\nExit." 4 40 + VALID="false" + sleep 5 fi # Copy DSM Files to Locations if DSM Files not found - if [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then - if copyDSMFiles "${UNTAR_PAT_PATH}" 2>/dev/null; then - VALID="true" - else - VALID="false" + if [ "${VALID}" == "true" ]; then + if [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then + if copyDSMFiles "${UNTAR_PAT_PATH}" 2>/dev/null; then + VALID="true" + else + VALID="false" + fi fi fi if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ] && [ "${VALID}" == "true" ]; then @@ -771,6 +790,8 @@ function make() { --progressbox "Doing the Magic..." 20 70 fi if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ] && [ -f "${MOD_ZIMAGE_FILE}" ] && [ -f "${MOD_RDGZ_FILE}" ]; then + writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" arcFinish else dialog --backtitle "$(backtitle)" --title "Build Loader" --aspect 18 \ @@ -788,13 +809,11 @@ function make() { function arcFinish() { # Verify Files exist CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" - # Build is done rm -f "${LOG_FILE}" >/dev/null - writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" # Check for Automated Mode if [ "${CUSTOM}" == "true" ]; then - boot && exit 0 + [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-${PRODUCTVER}-custom" >"${PART3_PATH}/automated" + boot elif [ "${CUSTOM}" == "false" ]; then [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null # Ask for Boot @@ -806,7 +825,7 @@ function arcFinish() { resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ ${resp} -eq 1 ]; then - boot && exit 0 + boot elif [ ${resp} -eq 2 ]; then return 0 fi @@ -982,7 +1001,7 @@ else 0) decryptMenu; NEXT="0" ;; 1) arcModel; NEXT="2" ;; 2) make; NEXT="3" ;; - 3) boot && exit 0 ;; + 3) boot; NEXT="3" ;; # Info Section a) sysinfo; NEXT="a" ;; A) networkdiag; NEXT="A" ;; diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 26231d23..6fb4b239 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -3,10 +3,9 @@ . ${ARC_PATH}/include/functions.sh ############################################################################### -# Update Loader -function updateLoader() { +# Upgrade Loader +function upgradeLoader () { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -14,9 +13,9 @@ function updateLoader() { idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break if [ "${ARCNIC}" == "auto" ]; then - TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" else - TAG="$(curl --interface ${ARCNIC} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" fi if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" @@ -31,7 +30,73 @@ function updateLoader() { updateFailed fi else - TAG=${1} + TAG="${1}" + fi + # Download update file + echo "Downloading ${TAG}" + if [ "${ARCNIC}" == "auto" ]; then + curl -#kL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip" 2>&1 | while IFS= read -r -n1 char; do + [[ $char =~ [0-9] ]] && keep=1 ; + [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $keep == 1 ]] && progress="$progress$char" ; + done + else + curl --interface ${ARCNIC} -#kL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip" 2>&1 | while IFS= read -r -n1 char; do + [[ $char =~ [0-9] ]] && keep=1 ; + [[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ; + [[ $keep == 1 ]] && progress="$progress$char" ; + done + fi + if [ -f "${TMP_PATH}/arc-${TAG}.img.zip" ]; then + echo "Downloading Upgradefile successful!" + else + echo "Error downloading Upgradefile!" + sleep 5 + return 1 + fi + unzip -oq "${TMP_PATH}/arc-${TAG}.img.zip" -d "${TMP_PATH}" + rm -f "${TMP_PATH}/arc-${TAG}.img.zip" >/dev/null + echo "Installing new Loader Image..." + # Process complete update + 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" >/dev/null + echo "Upgrade done! -> Rebooting..." + sleep 2 + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ + --progressbox "Upgrading Loader..." 20 70 +} + +############################################################################### +# Update Loader +function updateLoader() { + ( + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" + TAG="" + if [ -z "${1}" ]; then + # Check for new Version + idx=0 + while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break + if [ "${ARCNIC}" == "auto" ]; then + TAG="$(curl -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + else + TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + fi + 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 + updateFailed + fi + else + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -76,7 +141,6 @@ function updateLoader() { # Update Addons function updateAddons() { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -84,9 +148,9 @@ function updateAddons() { idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break if [ "${ARCNIC}" == "auto" ]; then - TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" else - TAG="$(curl --interface ${ARCNIC} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" fi if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" @@ -101,7 +165,7 @@ function updateAddons() { updateFailed fi else - TAG=${1} + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -136,7 +200,7 @@ function updateAddons() { rm -f "${F}" done else - echo "Error getting new Version!" + echo "Error extracting new Version!" sleep 5 updateFailed fi @@ -151,7 +215,6 @@ function updateAddons() { # Update Patches function updatePatches() { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -159,9 +222,9 @@ function updatePatches() { idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break if [ "${ARCNIC}" == "auto" ]; then - TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" else - TAG="$(curl --interface ${ARCNIC} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" fi if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" @@ -176,7 +239,7 @@ function updatePatches() { updateFailed fi else - TAG=${1} + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -218,7 +281,6 @@ function updatePatches() { # Update Modules function updateModules() { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -243,7 +305,7 @@ function updateModules() { updateFailed fi else - TAG=${1} + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -289,7 +351,7 @@ function updateModules() { done < <(getAllModules "${PLATFORM}" "${KVERP}") fi else - echo "Error getting new Version!" + echo "Error extracting new Version!" sleep 5 updateFailed fi @@ -304,7 +366,6 @@ function updateModules() { # Update Configs function updateConfigs() { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -329,7 +390,7 @@ function updateConfigs() { updateFailed fi else - TAG=${1} + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -356,7 +417,7 @@ function updateConfigs() { unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" rm -f "${TMP_PATH}/configs.zip" else - echo "Error getting new Version!" + echo "Error extracting new Version!" sleep 5 updateFailed fi @@ -371,7 +432,6 @@ function updateConfigs() { # Update LKMs function updateLKMs() { ( - local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then @@ -396,7 +456,7 @@ function updateLKMs() { updateFailed fi else - TAG=${1} + TAG="${1}" fi # Download update file echo "Downloading ${TAG}" @@ -421,7 +481,7 @@ function updateLKMs() { unzip -oq "${TMP_PATH}/rp-lkms.zip" -d "${LKMS_PATH}" rm -f "${TMP_PATH}/rp-lkms.zip" else - echo "Error getting new Version!" + echo "Error extracting new Version!" sleep 5 updateFailed fi diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index effc0650..6b272c91 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -32,9 +32,6 @@ offlineCheck # Get DSM Data from Config MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")" -KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" -LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" if [ -n "${MODEL}" ]; then PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" DT="$(readConfigKey "platforms.${PLATFORM}.dt" "${P_FILE}")" @@ -96,6 +93,7 @@ function arcUpdate() { ############################################################################### # Calls boot.sh to boot into DSM kernel/ramdisk function boot() { + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" if [ "${CONFDONE}" == "true" ]; then dialog --backtitle "$(backtitle)" --title "Arc Boot" \ --infobox "Rebooting to automated Build Mode...\nPlease stay patient!" 4 30