distribution/packages/jelos/sources/scripts/updatecheck
fewtarius 7c5704a7c9
Update behavior change
* This change alters system update behavior adding an additional check to ensure a release hash is available before sending an update available signal or attempting to fetch an update.  This allows the JELOS team to pause updates for certain devices when they may not be necessary or to pause support without breaking future update ability.
2023-11-21 13:02:19 +00:00

57 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
ORGANIZATION="${GIT_ORGANIZATION}"
BRANCH="$(get_setting updates.branch)"
case ${BRANCH} in
dev)
PROJECT="${GIT_REPO}-dev"
;;
*)
PROJECT="${GIT_REPO}"
;;
esac
GIT_REPO="https://github.com/${ORGANIZATION}/${PROJECT}"
GIT_API="https://api.github.com/repos/${ORGANIZATION}/${PROJECT}"
FORCE="$(get_setting updates.force)"
function check_network() {
GW=$(ip route | awk '/eth0/ {a=$0} END{print $1}')
if [[ ${GW} =~ [0-9] ]]
then
echo true
else
echo false
fi
}
function cleanup() {
if [ -e "/tmp/release.data" ]
then
rm -f /tmp/release.data
fi
}
ONLINE_STATUS=$(check_network)
if [ "${ONLINE_STATUS}" == true ]
then
curl -o /tmp/release.data -H 'Cache-Control: no-cache' -Ls "${GIT_API}/releases"
LATEST_RELEASE_TAG=$(cat /tmp/release.data | python -c "import sys, json; print(json.load(sys.stdin)[0]['tag_name'])")
UPDATE_PACKAGE=$((grep "${OS_NAME}-${HW_DEVICE}.${HW_ARCH}.*tar.sha256" /tmp/release.data >/dev/null 2>&1 && echo true ) || echo false)
if [ "${OS_VERSION}" -lt "${LATEST_RELEASE_TAG}" ] \
|| [ "${FORCE}" == "1" ] \
&& [ "${UPDATE_PACKAGE}" == "true" ]
then
echo "${LATEST_RELEASE_TAG}"
cleanup
exit 0
fi
fi
cleanup
exit 12