From ea9c7526d26df3236ae1b9629b427d04b9a33e4a Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 6 Jul 2024 10:45:06 +0200 Subject: [PATCH] arc: offlinemode rework Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc.sh | 6 +- files/initrd/opt/arc/include/functions.sh | 76 ++++++++++++----------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index a83e5415..e849537c 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -1193,9 +1193,9 @@ else x) backupMenu; NEXT="x" ;; M) arcNIC; NEXT="M" ;; 9) [ "${OFFLINE}" == "true" ] && OFFLINE='false' || OFFLINE='true' - [ "${OFFLINE}" == "false" ] && offlineCheck - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + offlineCheck "${OFFLINE}" + ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" + OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" NEXT="9" ;; y) keymapMenu; NEXT="y" ;; diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index eb339e25..32625735 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -539,47 +539,51 @@ function ntpCheck() { # Offline Check function offlineCheck() { CNT=0 - ARCNIC="" AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")" - while true; do - NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - CNT=$((${CNT} + 1)) - if [ -n "${NEWTAG}" ]; then - ARCNIC="auto" - break - elif [ ${CNT} -ge 3 ]; then - ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" - for ETH in ${ETHX}; do - # Update Check - NEWTAG="$(curl --interface ${ETH} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - if [ -n "${NEWTAG}" ]; then - ARCNIC="${ETH}" - break 2 - fi - done - break + local ARCNIC="" + local OFFLINE="${1}" + if [ "${OFFLINE}" == "true" ]; then + ARCNIC="offline" + OFFLINE="true" + elif [ "${OFFLINE}" == "false" ]; then + while true; do + NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + CNT=$((${CNT} + 1)) + if [ -n "${NEWTAG}" ]; then + ARCNIC="auto" + break + elif [ ${CNT} -ge 3 ]; then + ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" + for ETH in ${ETHX}; do + # Update Check + NEWTAG="$(curl --interface ${ETH} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + if [ -n "${NEWTAG}" ]; then + ARCNIC="${ETH}" + break 2 + fi + done + break + fi + done + if [ -n "${ARCNIC}" ]; then + OFFLINE="false" + elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "false" ]; then + dialog --backtitle "$(backtitle)" --title "Online Check" \ + --msgbox "Could not connect to Github.\nSwitch to Offline Mode!" 0 0 + cp -f "${PART3_PATH}/configs/offline.json" "${ARC_PATH}/include/offline.json" + ARCNIC="offline" + OFFLINE="true" + elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "true" ]; then + dialog --backtitle "$(backtitle)" --title "Online Check" \ + --msgbox "Could not connect to Github.\nSwitch to Offline Mode!\nDisable Automated Mode!" 0 0 + writeConfigKey "arc.automated" "false" "${USER_CONFIG_FILE}" + [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null + ARCNIC="offline" + OFFLINE="true" fi - done - if [ -n "${ARCNIC}" ]; then - OFFLINE="false" - elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "false" ]; then - dialog --backtitle "$(backtitle)" --title "Online Check" \ - --msgbox "Could not connect to Github.\nSwitch to Offline Mode!" 0 0 - cp -f "${PART3_PATH}/configs/offline.json" "${ARC_PATH}/include/offline.json" - ARCNIC="offline" - OFFLINE="true" - elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "true" ]; then - dialog --backtitle "$(backtitle)" --title "Online Check" \ - --msgbox "Could not connect to Github.\nSwitch to Offline Mode!\nDisable Automated Mode!" 0 0 - writeConfigKey "arc.automated" "false" "${USER_CONFIG_FILE}" - [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null - ARCNIC="offline" - OFFLINE="true" fi writeConfigKey "arc.nic" "${ARCNIC}" "${USER_CONFIG_FILE}" writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}" - ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" - OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" } ###############################################################################