84
cattools.sh
84
cattools.sh
@@ -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() {
|
||||
@@ -1009,17 +1021,17 @@ catwrt_opkg_list_installed() {
|
||||
|
||||
backup_installed_packages() {
|
||||
echo "名单中已安装软件包列表..."
|
||||
> "$BACKUP_FILE"
|
||||
>"$BACKUP_FILE"
|
||||
for package in "${PACKAGES[@]}"; do
|
||||
if opkg list_installed | grep -q "^$package "; then
|
||||
echo "$package" >> "$BACKUP_FILE"
|
||||
echo "$package" >>"$BACKUP_FILE"
|
||||
fi
|
||||
done
|
||||
echo "备份完成"
|
||||
}
|
||||
|
||||
restore_installed_packages() {
|
||||
opkg list_installed | awk '{print \$1}' > /tmp/default_installed_packages
|
||||
opkg list_installed | awk '{print \$1}' >/tmp/default_installed_packages
|
||||
if [ -f "$BACKUP_FILE" ]; then
|
||||
while IFS= read -r package; do
|
||||
if grep -q "^$package$" "$DEFAULT_PACKAGES_FILE"; then
|
||||
@@ -1030,7 +1042,7 @@ catwrt_opkg_list_installed() {
|
||||
echo "安装固件默认缺失的软件包: $package"
|
||||
opkg install "$package"
|
||||
fi
|
||||
done < "$BACKUP_FILE"
|
||||
done <"$BACKUP_FILE"
|
||||
echo "安装完成"
|
||||
else
|
||||
echo "未检测到备份文件!寄了!"
|
||||
@@ -1069,7 +1081,7 @@ catwrt_opkg_list_installed() {
|
||||
rm -f /tmp/default_installed_packages
|
||||
}
|
||||
main
|
||||
}
|
||||
}
|
||||
|
||||
# Utilities MENU
|
||||
utilities_menu() {
|
||||
@@ -1483,28 +1495,28 @@ patch_catwrt_release() {
|
||||
fi
|
||||
else
|
||||
if [ "$(uname -m)" == "mips" ] || [ "$(uname -m)" == "mipsel" ] && grep -q "R22.12.1" /etc/openwrt_release && grep -q "miaoer.xyz" /etc/banner; then
|
||||
echo "version=v22.12" > $RELEASE
|
||||
echo "arch=mt7621" >> $RELEASE
|
||||
echo "source=lean" >> $RELEASE
|
||||
echo "hash=a1682a48834efdc6c5e2c3c62921b3195d306c8c" >> $RELEASE
|
||||
echo "version=v22.12" >$RELEASE
|
||||
echo "arch=mt7621" >>$RELEASE
|
||||
echo "source=lean" >>$RELEASE
|
||||
echo "hash=a1682a48834efdc6c5e2c3c62921b3195d306c8c" >>$RELEASE
|
||||
echo "The patch file has been installed!"
|
||||
elif [ "$(uname -m)" == "aarch64" ] && grep -q "R22.12.1" /etc/openwrt_release && grep -q "miaoer.xyz" /etc/banner; then
|
||||
echo "version=v22.12" > $RELEASE
|
||||
echo "arch=rkarm" >> $RELEASE
|
||||
echo "source=lean" >> $RELEASE
|
||||
echo "hash=3fd4930e781e40e3f85e2c6c082d6fcdd544e9ce" >> $RELEASE
|
||||
echo "version=v22.12" >$RELEASE
|
||||
echo "arch=rkarm" >>$RELEASE
|
||||
echo "source=lean" >>$RELEASE
|
||||
echo "hash=3fd4930e781e40e3f85e2c6c082d6fcdd544e9ce" >>$RELEASE
|
||||
echo "The patch file has been installed!"
|
||||
elif [ "$(uname -m)" == "x86_64" ] && grep -q "R23.2" /etc/openwrt_release && grep -q "miaoer.xyz" /etc/banner; then
|
||||
echo "version=v23.2" > $RELEASE
|
||||
echo "arch=amd64" >> $RELEASE
|
||||
echo "source=lean" >> $RELEASE
|
||||
echo "hash=0239fab82eb640b55d4f4050cbc227ffd22087f3" >> $RELEASE
|
||||
echo "version=v23.2" >$RELEASE
|
||||
echo "arch=amd64" >>$RELEASE
|
||||
echo "source=lean" >>$RELEASE
|
||||
echo "hash=0239fab82eb640b55d4f4050cbc227ffd22087f3" >>$RELEASE
|
||||
echo "The patch file has been installed!"
|
||||
elif [ "$(uname -m)" == "x86_64" ] && grep -q "R22.11.11" /etc/openwrt_release && grep -q "miaoer.xyz" /etc/banner; then
|
||||
echo "version=v22.12" > $RELEASE
|
||||
echo "arch=amd64" >> $RELEASE
|
||||
echo "source=lean" >> $RELEASE
|
||||
echo "hash=4d6877d960c5c3bdc01b8e47679d923b475bea82" >> $RELEASE
|
||||
echo "version=v22.12" >$RELEASE
|
||||
echo "arch=amd64" >>$RELEASE
|
||||
echo "source=lean" >>$RELEASE
|
||||
echo "hash=4d6877d960c5c3bdc01b8e47679d923b475bea82" >>$RELEASE
|
||||
echo "The patch file has been installed!"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user