Update cattools.sh
This commit is contained in:
54
cattools.sh
54
cattools.sh
@@ -144,7 +144,7 @@ network_wizard() {
|
|||||||
if [[ -z $input_ip ]]; then
|
if [[ -z $input_ip ]]; then
|
||||||
input_ip=$DEFAULT_IP
|
input_ip=$DEFAULT_IP
|
||||||
elif ! [[ $input_ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
|
elif ! [[ $input_ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
|
||||||
echo "无效的 IP 地址。"
|
echo "无效的 IP 地址"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ network_wizard() {
|
|||||||
/etc/init.d/firewall restart
|
/etc/init.d/firewall restart
|
||||||
/etc/init.d/miniupnpd restart
|
/etc/init.d/miniupnpd restart
|
||||||
echo "Network configuration saved and applied. If you encounter any issues, please restart!"
|
echo "Network configuration saved and applied. If you encounter any issues, please restart!"
|
||||||
echo "网络配置已保存并应用,服务已重启,如遇到问题问题请手动重启!"
|
echo "网络配置已保存并应用,服务已重启,如遇到问题问题请手动重启!"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,20 +336,19 @@ debug() {
|
|||||||
# catwrt_update
|
# catwrt_update
|
||||||
catwrt_update() {
|
catwrt_update() {
|
||||||
|
|
||||||
API_URL="https://api.miaoer.xyz/api/v2/snippets/catwrt/update"
|
API_URL="https://api.miaoer.xyz/api/v2/snippets/catwrt/update"
|
||||||
VERSION_FILE="/etc/catwrt_release"
|
|
||||||
|
|
||||||
remote_error() {
|
remote_error() {
|
||||||
echo "Remote $1 get failed for arch: $arch_self, please check your network!"
|
echo "Remote $1 get failed for arch: $arch_self, please check your network!"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
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_hash() {
|
get_remote_hash() {
|
||||||
arch_self=$1
|
arch_self=$1
|
||||||
version_remote=$(curl -s "$API_URL" | jq -r ".$arch_self.version")
|
version_remote=$(curl -s "$API_URL" | jq -r ".$arch_self.version")
|
||||||
hash_remote=$(curl -s "$API_URL" | jq -r ".$arch_self.hash")
|
hash_remote=$(curl -s "$API_URL" | jq -r ".$arch_self.hash")
|
||||||
@@ -357,20 +356,20 @@ get_remote_hash() {
|
|||||||
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"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if [ ! -f "$VERSION_FILE" ]; then
|
if [ ! -f "$RELEASE" ]; then
|
||||||
local_error "version file"
|
local_error "version file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version_local=$(grep 'version' "$VERSION_FILE" | cut -d '=' -f 2)
|
version_local=$(grep 'version' "$RELEASE" | cut -d '=' -f 2)
|
||||||
hash_local=$(grep 'hash' "$VERSION_FILE" | cut -d '=' -f 2)
|
hash_local=$(grep 'hash' "$RELEASE" | cut -d '=' -f 2)
|
||||||
source_local=$(grep 'source' "$VERSION_FILE" | cut -d '=' -f 2)
|
source_local=$(grep 'source' "$RELEASE" | cut -d '=' -f 2)
|
||||||
arch_local=$(grep 'arch' "$VERSION_FILE" | cut -d '=' -f 2)
|
arch_local=$(grep 'arch' "$RELEASE" | cut -d '=' -f 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 up to date!"
|
||||||
@@ -381,25 +380,25 @@ contrast_version() {
|
|||||||
echo "You can visit 'https://www.miaoer.xyz/posts/network/catwrt' to get more information!"
|
echo "You can visit 'https://www.miaoer.xyz/posts/network/catwrt' to get more information!"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
print_version() {
|
print_version() {
|
||||||
echo "Local Version : $version_local"
|
echo "Local Version : $version_local"
|
||||||
echo "Remote Version : $version_remote"
|
echo "Remote Version : $version_remote"
|
||||||
echo "Local Hash : $hash_local"
|
echo "Local Hash : $hash_local"
|
||||||
echo "Remote Hash : $hash_remote"
|
echo "Remote Hash : $hash_remote"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
init
|
init
|
||||||
get_remote_hash "$arch_local"
|
get_remote_hash "$arch_local"
|
||||||
contrast_version
|
contrast_version
|
||||||
print_version
|
print_version
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
}
|
}
|
||||||
|
|
||||||
# Repo
|
# Repo
|
||||||
apply_repo() {
|
apply_repo() {
|
||||||
@@ -839,7 +838,7 @@ configure_tailscale(){
|
|||||||
menu
|
menu
|
||||||
}
|
}
|
||||||
|
|
||||||
# TTYD
|
# TTYD (NOT SAFETY)
|
||||||
configure_ttyd(){
|
configure_ttyd(){
|
||||||
if ! opkg list_installed | grep -q "luci-app-ttyd" || ! opkg list_installed | grep -q "ttyd"; then
|
if ! opkg list_installed | grep -q "luci-app-ttyd" || ! opkg list_installed | grep -q "ttyd"; then
|
||||||
echo "[ERROR]未安装 luci-app-ttyd 或 ttyd 软件包,请先配置软件源并安装这些软件包"
|
echo "[ERROR]未安装 luci-app-ttyd 或 ttyd 软件包,请先配置软件源并安装这些软件包"
|
||||||
@@ -981,6 +980,8 @@ manual_deploy_uhttpd_ssl_cert() {
|
|||||||
menu
|
menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Firstboot
|
||||||
|
|
||||||
openwrt_firstboot() {
|
openwrt_firstboot() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "Warning:"
|
echo "Warning:"
|
||||||
@@ -1008,6 +1009,7 @@ openwrt_firstboot() {
|
|||||||
firstboot && reboot
|
firstboot && reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Reset password
|
||||||
reset_root_password() {
|
reset_root_password() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "此操作将重置 root 用户的密码"
|
echo "此操作将重置 root 用户的密码"
|
||||||
|
|||||||
Reference in New Issue
Block a user