arc: offlinemode rework

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-07-06 10:45:06 +02:00
parent 4ad6f52ed9
commit ea9c7526d2
2 changed files with 43 additions and 39 deletions

View File

@ -1193,9 +1193,9 @@ else
x) backupMenu; NEXT="x" ;; x) backupMenu; NEXT="x" ;;
M) arcNIC; NEXT="M" ;; M) arcNIC; NEXT="M" ;;
9) [ "${OFFLINE}" == "true" ] && OFFLINE='false' || OFFLINE='true' 9) [ "${OFFLINE}" == "true" ] && OFFLINE='false' || OFFLINE='true'
[ "${OFFLINE}" == "false" ] && offlineCheck offlineCheck "${OFFLINE}"
writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
NEXT="9" NEXT="9"
;; ;;
y) keymapMenu; NEXT="y" ;; y) keymapMenu; NEXT="y" ;;

View File

@ -539,47 +539,51 @@ function ntpCheck() {
# Offline Check # Offline Check
function offlineCheck() { function offlineCheck() {
CNT=0 CNT=0
ARCNIC=""
AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")" AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")"
while true; do local ARCNIC=""
NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" local OFFLINE="${1}"
CNT=$((${CNT} + 1)) if [ "${OFFLINE}" == "true" ]; then
if [ -n "${NEWTAG}" ]; then ARCNIC="offline"
ARCNIC="auto" OFFLINE="true"
break elif [ "${OFFLINE}" == "false" ]; then
elif [ ${CNT} -ge 3 ]; then while true; do
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
for ETH in ${ETHX}; do CNT=$((${CNT} + 1))
# Update Check if [ -n "${NEWTAG}" ]; then
NEWTAG="$(curl --interface ${ETH} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" ARCNIC="auto"
if [ -n "${NEWTAG}" ]; then break
ARCNIC="${ETH}" elif [ ${CNT} -ge 3 ]; then
break 2 ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
fi for ETH in ${ETHX}; do
done # Update Check
break 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 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 fi
writeConfigKey "arc.nic" "${ARCNIC}" "${USER_CONFIG_FILE}" writeConfigKey "arc.nic" "${ARCNIC}" "${USER_CONFIG_FILE}"
writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}" writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}"
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
} }
############################################################################### ###############################################################################