diff --git a/install.sh b/install.sh index 08cbb9d..8680f5e 100755 --- a/install.sh +++ b/install.sh @@ -56,6 +56,6 @@ clashsecret clashctl # shellcheck disable=SC2016 [ "$SUDO_USER" != 'root' ] && _okcat '请执行 clashon 开启代理环境' -_okcat '🎉' 'enjoy 🎉' clashupgrade +_okcat '🎉' 'enjoy 🎉' _quit diff --git a/resources/mixin.yaml b/resources/mixin.yaml index ecad5c7..deebfb3 100644 --- a/resources/mixin.yaml +++ b/resources/mixin.yaml @@ -17,7 +17,8 @@ authentication: # override:根据 name 匹配并替换原项 rules: prefix: - - DOMAIN,api64.ipify.org,DIRECT #用于 clashui 获取真实公网 IP + - DOMAIN,api64.ipify.org,DIRECT # 用于 clashui 获取真实公网 IP + # - DOMAIN-KEYWORD,github,proxy # 用于 clashupgrade 升级内核 suffix: proxies: diff --git a/script/clashctl.sh b/script/clashctl.sh index e95eb0a..0994072 100644 --- a/script/clashctl.sh +++ b/script/clashctl.sh @@ -66,6 +66,21 @@ clashrestart() { function clashproxy() { case "$1" in + -h | --help) + cat <&/dev/null || { _failcat '代理程序未运行,请执行 clashon 开启代理环境' @@ -80,7 +95,7 @@ function clashproxy() { _unset_system_proxy _okcat '已关闭系统代理' ;; - status) + *) local system_proxy_status=$(sudo "$BIN_YQ" '._custom.system-proxy.enable' "$CLASH_CONFIG_MIXIN" 2>/dev/null) [ "$system_proxy_status" = "false" ] && { _failcat "系统代理:关闭" @@ -90,14 +105,6 @@ function clashproxy() { http_proxy: $http_proxy socks_proxy:$all_proxy" ;; - *) - cat < + +EOF + return 0 + ;; + esac + case "$#" in 0) _okcat "当前密钥:$(sudo "$BIN_YQ" '.secret // ""' "$CLASH_CONFIG_RUNTIME")" @@ -245,6 +267,21 @@ _tunon() { function clashtun() { case "$1" in + -h | --help) + cat </dev/null + } local res=$( curl -X POST \ --silent \ @@ -360,8 +426,9 @@ EOF -H "Authorization: Bearer $secret" \ "http://${EXT_IP}:${EXT_PORT}/upgrade?channel=$channel" ) + [ "$log_flag" = true ] && kill -9 "$log_pid" >&/dev/null - grep -qs '"status":"ok"' <<<"$res" && { + grep '"status":"ok"' <<<"$res" && { _okcat "内核升级成功" return 0 } @@ -369,8 +436,7 @@ EOF _okcat "已是最新版本" return 0 } - _failcat "升级请求失败,请检查网络或稍后重试" - + _failcat "内核升级失败,请检查网络或稍后重试" } function clashctl() { @@ -421,20 +487,24 @@ function clashctl() { clashhelp() { cat <