Update: test code

This commit is contained in:
喵二
2024-07-17 20:16:38 +08:00
parent 7467122858
commit 227e107cd9

View File

@@ -482,16 +482,17 @@ catwrt_update() {
} }
local_error() { local_error() {
echo "Local $1 get failed, please check your /etc/catwrt-release!" echo "Local $1 get failed, please check your /etc/catwrt_release!"
exit 1 exit 1
} }
get_remote_info() { get_remote_info() {
version_remote=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local.version") local arch_version_json=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local")
hash_remote=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local.hash") version_remote=$(echo "$arch_version_json" | jq -r '.version')
releases_remote=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local.releases") hash_remote=$(echo "$arch_version_json" | jq -r '.hash')
blog_remote=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local.blogs") releases_remote=$(echo "$arch_version_json" | jq -r '.releases')
channel_remote=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local.channel") blog_remote=$(echo "$arch_version_json" | jq -r '.blogs')
channel_remote=$(echo "$arch_version_json" | jq -r '.channel')
if [ $? -ne 0 ] || [ -z "$version_remote" ] || [ -z "$hash_remote" ]; then if [ $? -ne 0 ] || [ -z "$version_remote" ] || [ -z "$hash_remote" ]; then
remote_error "version or hash" remote_error "version or hash"
@@ -512,19 +513,28 @@ catwrt_update() {
contrast_version() { contrast_version() {
if [ "$version_remote" == "$version_local" ] && [ "$hash_remote" == "$hash_local" ]; then if [ "$version_remote" == "$version_local" ] && [ "$hash_remote" == "$hash_local" ]; then
echo "=======================================================" echo "======================================================="
echo " Your CatWrt is up to date!" echo " Your CatWrt is $releases_remote"
echo "=======================================================" echo "======================================================="
else else
if [ "$channel_remote" == "Stable" ] || ( [ "$channel_remote" == "Beta" ] && [ "$channel_local" == "Beta" ] ); then
echo "=======================================================" echo "======================================================="
echo "Your CatWrt is out of date, you should upgrade it!" echo "Your CatWrt is $releases_remote, you should upgrade it!"
echo "Visit the blog for more information" echo "Visit the blog for more information"
echo "$blog_remote" echo "$blog_remote"
echo "=======================================================" echo "======================================================="
else
echo "======================================================="
echo " Your CatWrt is up to date!"
echo "======================================================="
fi
fi fi
} }
print_version() { print_version() {
echo "Release : $releases_remote" echo "Local Version : $version_local"
echo "Remote Version : $releases_remote"
echo "Local Hash : $hash_local"
echo "Remote Hash : $hash_remote"
echo "Channel : $channel_remote" echo "Channel : $channel_remote"
echo "=======================================================" echo "======================================================="
echo "" echo ""