2022-03-08 11:48:16 +00:00
|
|
|
#!/bin/bash
|
2023-10-23 22:44:47 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2023-10-24 16:00:57 +00:00
|
|
|
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
2022-03-08 11:48:16 +00:00
|
|
|
|
|
|
|
. /etc/profile
|
|
|
|
|
2022-12-04 15:12:10 +00:00
|
|
|
ORGANIZATION="${GIT_ORGANIZATION}"
|
2022-04-12 20:42:13 +00:00
|
|
|
BRANCH="$(get_setting updates.branch)"
|
2022-12-04 15:12:10 +00:00
|
|
|
case ${BRANCH} in
|
|
|
|
dev)
|
|
|
|
PROJECT="${GIT_REPO}-dev"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PROJECT="${GIT_REPO}"
|
|
|
|
;;
|
|
|
|
esac
|
2022-04-12 20:42:13 +00:00
|
|
|
|
|
|
|
GIT_REPO="https://github.com/${ORGANIZATION}/${PROJECT}"
|
|
|
|
GIT_API="https://api.github.com/repos/${ORGANIZATION}/${PROJECT}"
|
|
|
|
|
2022-04-11 23:43:19 +00:00
|
|
|
FORCE="$(get_setting updates.force)"
|
2022-03-08 11:48:16 +00:00
|
|
|
|
|
|
|
function check_network() {
|
|
|
|
GW=$(ip route | awk '/eth0/ {a=$0} END{print $1}')
|
|
|
|
if [[ ${GW} =~ [0-9] ]]
|
|
|
|
then
|
|
|
|
echo true
|
|
|
|
else
|
|
|
|
echo false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-11-21 13:02:19 +00:00
|
|
|
function cleanup() {
|
|
|
|
if [ -e "/tmp/release.data" ]
|
|
|
|
then
|
|
|
|
rm -f /tmp/release.data
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-08 11:48:16 +00:00
|
|
|
ONLINE_STATUS=$(check_network)
|
|
|
|
if [ "${ONLINE_STATUS}" == true ]
|
|
|
|
then
|
2023-11-21 13:02:19 +00:00
|
|
|
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" ]
|
2022-03-08 11:48:16 +00:00
|
|
|
then
|
2023-11-21 13:02:19 +00:00
|
|
|
echo "${LATEST_RELEASE_TAG}"
|
|
|
|
cleanup
|
2022-03-08 11:48:16 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-11-21 13:02:19 +00:00
|
|
|
cleanup
|
2022-03-08 11:48:16 +00:00
|
|
|
exit 12
|