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.
This commit is contained in:
fewtarius 2023-11-21 13:02:19 +00:00
parent 1c92935788
commit 7c5704a7c9
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
2 changed files with 32 additions and 9 deletions

View file

@ -74,6 +74,13 @@ get_release_list() {
fi fi
} }
function cleanup() {
if [ -e "/tmp/release.data" ]
then
rm -f /tmp/release.data
fi
}
### ###
### Check for passed arguments. If we receive changelog, fetch it. If we receive a version, force install it. ### Check for passed arguments. If we receive changelog, fetch it. If we receive a version, force install it.
### ###
@ -113,10 +120,14 @@ fi
if [ -z "${LATEST_RELEASE_TAG}" ] if [ -z "${LATEST_RELEASE_TAG}" ]
then then
# Download curl -o /tmp/release.data -H 'Cache-Control: no-cache' -Ls "${GIT_API}/releases"
LATEST_RELEASE_TAG=$(curl -H 'Cache-Control: no-cache' -Ls "${GIT_API}/releases" | python -c "import sys, json; print(json.load(sys.stdin)[0]['tag_name'])") LATEST_RELEASE_TAG=$(cat /tmp/release.data | python -c "import sys, json; print(json.load(sys.stdin)[0]['tag_name'])")
if [ "${OS_VERSION}" -ge "${LATEST_RELEASE_TAG}" ] && [ ! "${FORCE}" = "1" ] 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}" -ge "${LATEST_RELEASE_TAG}" ] \
&& [ ! "${FORCE}" == "1" ] \
|| [ ! "${UPDATE_PACKAGE}" == "true" ]
then then
cleanup
echo "No new updates are available..." echo "No new updates are available..."
echo "Exiting in 5 seconds..." && sleep 5 echo "Exiting in 5 seconds..." && sleep 5
exit 0 exit 0
@ -124,9 +135,9 @@ then
fi fi
echo -e "\nFetching: ${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}" echo -e "\nFetching: ${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}"
curl -Lo "${UPDATE_PATH}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}" "${GIT_REPO}/releases/download/${LATEST_RELEASE_TAG}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.tar" curl -Lo "${UPDATE_PATH}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}" "${GIT_REPO}/releases/download/${LATEST_RELEASE_TAG}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.tar"
echo -e "Fetching: ${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}.sha256" echo -e "Fetching: ${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}.sha256"
curl -Lo "${UPDATE_PATH}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}.sha256" "${GIT_REPO}/releases/download/${LATEST_RELEASE_TAG}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.tar.sha256" curl -Lo "${UPDATE_PATH}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.${EXTENSION}.sha256" "${GIT_REPO}/releases/download/${LATEST_RELEASE_TAG}/${OS_NAME}-${HW_DEVICE}.${HW_ARCH}-${LATEST_RELEASE_TAG}.tar.sha256"
echo -e "\nVerifying download, please wait..." echo -e "\nVerifying download, please wait..."
# Verify # Verify

View file

@ -30,16 +30,28 @@ function check_network() {
fi fi
} }
function cleanup() {
if [ -e "/tmp/release.data" ]
then
rm -f /tmp/release.data
fi
}
ONLINE_STATUS=$(check_network) ONLINE_STATUS=$(check_network)
if [ "${ONLINE_STATUS}" == true ] if [ "${ONLINE_STATUS}" == true ]
then then
LATEST_RELEASE_TAG=$(curl -H 'Cache-Control: no-cache' -Ls "${GIT_API}/releases" | python -c "import sys, json; print(json.load(sys.stdin)[0]['tag_name'])") 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'])")
if [ "${OS_VERSION}" -lt "${LATEST_RELEASE_TAG}" ] || [ "${FORCE}" == "1" ] 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 then
echo "${TAG}" echo "${LATEST_RELEASE_TAG}"
cleanup
exit 0 exit 0
fi fi
fi fi
cleanup
exit 12 exit 12