diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 9df6850f..a608927f 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -6,6 +6,7 @@ # Upgrade Loader function upgradeLoader () { local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" + local AUTOMATED="$(readConfigKey "automated" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then # Check for new Version @@ -26,6 +27,20 @@ function upgradeLoader () { TAG="${1}" fi if [ -n "${TAG}" ]; then + curl -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/check.update" -o "${TMP_PATH}/check.update" + if [ -f "${TMP_PATH}/check.update" ]; then + UPDATE=$(cat "${TMP_PATH}/check.update" | sed -e 's/\.//g' ) + ARC_VERSION=$(cat "${PART1_PATH}/ARC-VERSION" | sed -e 's/\.//g' ) + if [ ${ARC_VERSION} -lt ${UPDATE} ]; then + dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ + --yesno "Current Config not compatible to new Version!\nDo not restore Config!\nDo you want to upgrade?" 0 0 + if [ $? -eq 0 ]; then + rm -f "${TMP_PATH}/check.update" + else + return 1 + fi + fi + fi ( # Download update file echo "Downloading ${TAG}" @@ -69,6 +84,7 @@ function upgradeLoader () { # Update Loader function updateLoader() { local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" + local AUTOMATED="$(readConfigKey "automated" "${USER_CONFIG_FILE}")" TAG="" if [ -z "${1}" ]; then # Check for new Version @@ -89,6 +105,25 @@ function updateLoader() { TAG="${1}" fi if [ -n "${TAG}" ]; then + curl -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/check.update" -o "${TMP_PATH}/check.update" + if [ -f "${TMP_PATH}/check.update" ]; then + UPDATE_VERSION=$(cat "${TMP_PATH}/check.update" | sed -e 's/\.//g' ) + ARC_VERSION=$(cat "${PART1_PATH}/ARC-VERSION" | sed -e 's/\.//g' ) + if [ ${ARC_VERSION} -lt ${UPDATE_VERSION} ] && [ "${AUTOMATED}" == "false" ]; then + dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ + --yesno "Config is not compatible to new Version!\nPlease reconfigure Loader after Update!\nDo you want to update?" 0 0 + if [ $? -eq 0 ]; then + rm -f "${TMP_PATH}/check.update" + else + return 1 + fi + elif [ ${ARC_VERSION} -lt ${UPDATE_VERSION} ] && [ "${AUTOMATED}" == "true" ]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" \ + --infobox "Config is not compatible to new Version!\nUpdate not possible!\nPlease reflash Loader." 0 0 + sleep 5 + updateFailed + fi + fi ( # Download update file echo "Downloading ${TAG}"