Merge pull request #12 from ttimochan/main

fix: catwrt-update
This commit is contained in:
喵二
2024-07-18 22:30:31 +08:00
committed by GitHub

View File

@@ -487,12 +487,23 @@ catwrt_update() {
}
get_remote_info() {
local arch_version_json=$(curl -s "$API_URL" | jq -r ".[\"$version_local\"].$arch_local")
version_remote=$(echo "$arch_version_json" | jq -r '.version')
hash_remote=$(echo "$arch_version_json" | jq -r '.hash')
releases_remote=$(echo "$arch_version_json" | jq -r '.releases')
blog_remote=$(echo "$arch_version_json" | jq -r '.blogs')
channel_remote=$(echo "$arch_version_json" | jq -r '.channel')
json_data=$(curl -s "$API_URL")
result=$(echo "$json_data" | jq --arg hash "$hash_local" '
. as $root |
paths(scalars) as $p |
if getpath($p) == $hash then
$p[0] as $version |
$p[1] as $device |
{version: $version, device: $device} + $root[$version][$device]
else empty end
| select(.version != null)
')
version_remote=$(echo "$result" | jq -r '.version')
channel_remote=$(echo "$result" | jq -r '.channel')
blog_remote=$(echo "$result" | jq -r '.blogs')
hash_remote=$(echo "$result" | jq -r '.hash')
latest=$(echo "$result" | jq -r '.latest')
if [ $? -ne 0 ] || [ -z "$version_remote" ] || [ -z "$hash_remote" ]; then
remote_error "version or hash"
@@ -511,23 +522,24 @@ catwrt_update() {
}
contrast_version() {
if [ "$version_remote" == "$version_local" ] && [ "$hash_remote" == "$hash_local" ]; then
if [ "$latest" == "true" ]; then
echo "======================================================="
echo " Your CatWrt is $releases_remote"
echo " Your CatWrt is up to date!"
echo " Remote Channel: $channel_remote"
if [ "$channel_remote" == "Beta" ]; then
echo " Please watch the latest version changes"
else
echo " You are on the stable version."
fi
echo "======================================================="
else
if [ "$channel_remote" == "Stable" ] || ( [ "$channel_remote" == "Beta" ] && [ "$channel_local" == "Beta" ] ); then
echo "======================================================="
echo "Your CatWrt is $releases_remote, you should upgrade it!"
echo "Your CatWrt is $version_local, the latest version is $version_remote,you should upgrade it!"
echo "Visit the blog for more information"
echo "$blog_remote"
echo "======================================================="
else
echo "======================================================="
echo " Your CatWrt is up to date!"
echo "======================================================="
fi
fi
}
print_version() {