tree: rework IV

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium
2024-07-04 20:37:50 +02:00
parent db6e493a2d
commit 4d4a5fd980
4 changed files with 51 additions and 68 deletions

View File

@@ -14,16 +14,14 @@
. ${ARC_PATH}/arc-functions.sh
. ${ARC_PATH}/boot.sh
[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!"
# Check for System
systemCheck
# Offline Mode check
offlineCheck
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")"
offlineCheck
# Get DSM Data from Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"

View File

@@ -496,44 +496,43 @@ function ntpCheck() {
# Offline Check
function offlineCheck() {
CNT=0
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
while true; do
NEWTAG="$(curl -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
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
break
elif [ ${CNT} -ge 3 ]; then
break
fi
done
if [ -n "${NEWTAG}" ]; then
[ -z "${ARCNIC}" ] && ARCNIC="auto"
elif [ -z "${NEWTAG}" ]; then
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
for ETH in ${ETHX}; do
# Update Check
NEWTAG="$(curl --interface ${ETH} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
if [ -n "${NEWTAG}" ]; then
[ -z "${ARCNIC}" ] && ARCNIC="${ETH}"
break
fi
done
if [ -n "${ARCNIC}" ]; then
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "false" ]; then
dialog --backtitle "$(backtitle)" --title "Online Check" \
--msgbox "Could not connect to Github.\nSwitch to Offline Mode!" 0 0
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}"
cp -f "${PART3_PATH}/configs/offline.json" "${ARC_PATH}/include/offline.json"
[ -z "${ARCNIC}" ] && ARCNIC="auto"
elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "true" ]; then
dialog --backtitle "$(backtitle)" --title "Online Check" \
--infobox "Could not connect to Github.\nReboot to try again!" 0 0
sleep 10
exec reboot
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
[ -z "${ARCNIC}" ] && ARCNIC="${ETH}"
break 2
fi
done
fi
break
done
if [ -n "${ARCNIC}" ]; then
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
elif [ -z "${ARCNIC}" ] && [ "${AUTOMATED}" == "false" ]; then
dialog --backtitle "$(backtitle)" --title "Online Check" \
--msgbox "Could not connect to Github.\nSwitch to Offline Mode!" 0 0
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}"
cp -f "${PART3_PATH}/configs/offline.json" "${ARC_PATH}/include/offline.json"
[ -z "${ARCNIC}" ] && ARCNIC="auto"
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.offline" "true" "${USER_CONFIG_FILE}"
writeConfigKey "arc.automated" "false" "${USER_CONFIG_FILE}"
[ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null
fi
writeConfigKey "arc.nic" "${ARCNIC}" "${USER_CONFIG_FILE}"
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
}
###############################################################################
@@ -541,6 +540,7 @@ function offlineCheck() {
function systemCheck () {
# Get Loader Disk Bus
BUS=$(getBus "${LOADER_DISK}")
[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!"
# Memory: Check Memory installed
RAMTOTAL="$(awk '/MemTotal:/ {printf "%.0f\n", $2 / 1024 / 1024 + 0.5}' /proc/meminfo 2>/dev/null)"
[ -z "${RAMTOTAL}" ] && RAMTOTAL="8"

View File

@@ -13,9 +13,9 @@ function upgradeLoader () {
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)"
TAG="$(curl -m 10 -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)"
TAG="$(curl --interface ${ARCNIC} -m 10 -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}"
@@ -79,9 +79,9 @@ function updateLoader() {
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)"
TAG="$(curl -m 10 -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)"
TAG="$(curl --interface ${ARCNIC} -m 10 -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}"
@@ -148,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 5 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
else
TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-addons/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl --interface ${ARCNIC} -m 10 -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}"
@@ -222,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 5 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
else
TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-patches/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl --interface ${ARCNIC} -m 10 -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}"
@@ -373,9 +373,9 @@ function updateConfigs() {
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-configs/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-configs/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
else
TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-configs/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl --interface ${ARCNIC} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-configs/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
fi
if [ -n "${TAG}" ]; then
echo "New Version: ${TAG}"
@@ -439,9 +439,9 @@ function updateLKMs() {
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-lkm/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-lkm/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
else
TAG="$(curl --interface ${ARCNIC} -m 5 -skL "https://api.github.com/repos/AuxXxilium/arc-lkm/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
TAG="$(curl --interface ${ARCNIC} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-lkm/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
fi
if [ -n "${TAG}" ]; then
echo "New Version: ${TAG}"

View File

@@ -11,23 +11,14 @@
. ${ARC_PATH}/include/update.sh
. ${ARC_PATH}/boot.sh
[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!"
# Check for Hypervisor
if grep -q "^flags.*hypervisor.*" /proc/cpuinfo; then
MACHINE="$(lscpu | grep Hypervisor | awk '{print $3}')"
else
MACHINE="Native"
fi
# Get Loader Disk Bus
BUS=$(getBus "${LOADER_DISK}")
# Check for System
systemCheck
# Offline Mode check
offlineCheck
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
AUTOMATED="$(readConfigKey "arc.automated" "${USER_CONFIG_FILE}")"
offlineCheck
# Get DSM Data from Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
@@ -113,14 +104,8 @@ function boot() {
if [ "${OFFLINE}" == "false" ]; then
arcUpdate
else
if [ "${AUTOMATED}" == "true" ]; then
dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \
--infobox "Offline Mode enabled.\nCan't Update Loader!" 0 0
sleep 5
bootDSM
else
dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \
--msgbox "Offline Mode enabled.\nCan't Update Loader!" 0 0
bootDSM
fi
dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \
--infobox "Offline Mode enabled.\nCan't Update Loader!" 0 0
sleep 5
bootDSM
fi