From eef719f5319160171db64e561f04e1fca9840653 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 4 Nov 2023 15:21:27 +0100 Subject: [PATCH] Revert "update: remove "update" option" This reverts commit f60b7b7326c258ee6dbec6c95cb6d3243dd29ad7. Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 74 +++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 5a4b6c28..95f58d41 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -1607,12 +1607,13 @@ function updateMenu() { while true; do dialog --backtitle "$(backtitle)" --menu "Choose an Option" 0 0 0 \ 1 "Upgrade Loader" \ - 2 "Update Addons" \ - 3 "Update Patches" \ - 4 "Update Extensions" \ - 5 "Update Modules" \ - 6 "Update Configs" \ - 7 "Update LKMs" \ + 2 "Update Loader" \ + 3 "Update Addons" \ + 4 "Update Patches" \ + 5 "Update Extensions" \ + 6 "Update Modules" \ + 7 "Update Configs" \ + 8 "Update LKMs" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 case "$(<"${TMP_PATH}/resp")" in @@ -1685,6 +1686,57 @@ function updateMenu() { exit 0 ;; 2) + # Ask for 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="$(<"${TMP_PATH}/opts")" + [ -z "${opts}" ] && return 1 + if [ ${opts} -eq 1 ]; then + TAG="$(curl --insecure -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 + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --msgbox "Error checking new version" 0 0 + return 1 + fi + elif [ ${opts} -eq 2 ]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" \ + --inputbox "Type the Version!" 0 0 \ + 2>"${TMP_PATH}/input" + TAG="$(<"${TMP_PATH}/input")" + [ -z "${TAG}" ] && continue + fi + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + 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 ] || [ ${STATUS} -ne 200 ]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --msgbox "Error downloading" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Extracting" 0 0 + [ -f "${TMP_PATH}/update" ] && rm -rf "${TMP_PATH}/update" + mkdir -p "${TMP_PATH}/update" + unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}/update" >/dev/null 2>&1 + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Updating Loader Image" 0 0 + cp -f "${TMP_PATH}/update/bzImage" "${PART3_PATH}/bzImage-arc" + cp -f "${TMP_PATH}/update/rootfs.cpio.xz" "${PART3_PATH}/initrd-arc" + cp -f "${TMP_PATH}/update/ARC-VERSION" "${PART1_PATH}/ARC-VERSION" + cp -f "${TMP_PATH}/update/grub.cfg" "${PART1_PATH}/boot/grub/grub.cfg" + rm -rf "${TMP_PATH}/update" + rm -f "${TMP_PATH}/update.zip" + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --yesno "Arc updated with success to ${TAG}!\nReboot?" 0 0 + [ $? -ne 0 ] && continue + exec reboot + exit 0 + ;; + 3) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update Addons" \ --menu "Which Version?" 0 0 0 \ @@ -1736,7 +1788,7 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ --msgbox "Addons updated with success! ${TAG}" 0 0 ;; - 3) + 4) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update Patches" \ --menu "Which Version?" 0 0 0 \ @@ -1778,7 +1830,7 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ --msgbox "Patches updated with success! ${TAG}" 0 0 ;; - 4) + 5) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update Extensions" \ --menu "Which Version?" 0 0 0 \ @@ -1829,7 +1881,7 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Extensions" --aspect 18 \ --msgbox "Extensions updated with success! ${TAG}" 0 0 ;; - 5) + 6) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update Modules" \ --menu "Which Version?" 0 0 0 \ @@ -1882,7 +1934,7 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ --msgbox "Modules updated to ${TAG} with success!" 0 0 ;; - 6) + 7) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update Configs" \ --menu "Which Version?" 0 0 0 \ @@ -1924,7 +1976,7 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ --msgbox "Configs updated with success! ${TAG}" 0 0 ;; - 7) + 8) # Ask for Tag dialog --clear --backtitle "$(backtitle)" --title "Update LKMs" \ --menu "Which Version?" 0 0 0 \