~配置文件覆写功能增加退出时的重启提示
~检查更新时增加剩余空间检测及报警(<5M)
~修复启用软固化一直提示未配置及有关报错问题
~修复每次重启时重复添加多个自定义代理的bug
~修复linux系统下将运行日志错误打印到硬盘的bug
~配置文件覆写功能相关报错修复
This commit is contained in:
juewuy
2023-06-25 14:02:12 +08:00
parent e14a02f35e
commit c491c58281
7 changed files with 26 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -2,5 +2,5 @@ clashnet_v=v1.7.6
clashpre_v=2022.11.25
clash_v=v1.7.1
meta_v=v1.14.4
versionsh=1.7.9e
GeoIP_v=20230624
versionsh=1.7.9f

View File

@@ -888,7 +888,7 @@ localproxy(){
[ -f /etc/rc.common -a -w /etc/passwd ] && local_enh=1
echo -----------------------------------------------
[ -n "$local_enh" ] && {
[ -n "$(lsmod | grep ^xt_owner)" ] && echo -e " 1 使用\033[32miptables增强模式\033[0m配置(支持docker,推荐!)"
ckcmd iptables && [ -n "$(lsmod | grep ^xt_owner)" ] && echo -e " 1 使用\033[32miptables增强模式\033[0m配置(支持docker,推荐!)"
ckcmd nft && echo -e " 2 使用\033[32mnftables增强模式\033[0m配置(支持docker,推荐!)"
}
echo -e " 3 使用\033[33m环境变量\033[0m方式配置(部分应用可能无法使用,不推荐!)"
@@ -1499,7 +1499,7 @@ autoSSH(){
mi_autoSSH=已配置
cp -f /etc/dropbear/dropbear_rsa_host_key $clashdir/dropbear_rsa_host_key 2>/dev/null
cp -f /etc/dropbear/authorized_keys $clashdir/authorized_keys 2>/dev/null
cwcmd nvram && {
ckcmd nvram && {
nvram set ssh_en=1
nvram set telnet_en=1
nvram set uart_en=1
@@ -1578,7 +1578,7 @@ tools(){
}
#获取设置默认显示
[ -n "$(cat /etc/crontabs/root 2>&1| grep otapredownload)" ] && mi_update=禁用 || mi_update=启用
[ "$mi_autoSSH" = "已启用" ] && mi_autoSSH_type=32m已配置 || mi_autoSSH_type=31m未配置
[ "$mi_autoSSH" = "已配置" ] && mi_autoSSH_type=32m已配置 || mi_autoSSH_type=31m未配置
[ -f $clashdir/tun.ko ] && mi_tunfix=32m已启用 || mi_tunfix=31m未启用
#
echo -----------------------------------------------

View File

@@ -6,6 +6,9 @@ error_down(){
sleep 1
setserver
}
dir_avail(){
df $2 $1 |awk '{ for(i=1;i<=NF;i++){ if(NR==1){ arr[i]=$i; }else{ arr[i]=arr[i]" "$i; } } } END{ for(i=1;i<=NF;i++){ print arr[i]; } }' |grep Ava |awk '{print $2}'
}
#导入订阅、配置文件相关
linkconfig(){
echo -----------------------------------------------
@@ -350,7 +353,7 @@ setgroups(){
set_group_type(){
echo -----------------------------------------------
echo -e "\033[33m注意策略组名称必须和【自定义规则】或【自定义节点】功能中指定的策略组一致\033[0m"
echo -e "\033[33m建议先创建策略组之后可在【自定义规则】或【自定义节点】功能中自动指定\033[0m"
echo -e "\033[33m建议先创建策略组之后可在【自定义规则】或【自定义节点】功能中智能指定\033[0m"
echo -e "\033[33m如需在当前策略组下添加节点请手动编辑$clashdir/proxy-groups.yaml\033[0m"
read -p "请输入自定义策略组名称(不支持纯数字) > " new_group_name
echo -----------------------------------------------
@@ -419,7 +422,7 @@ EOF
1)
group_type="select url-test fallback load-balance"
group_type_cn="手动选择 自动选择 故障转移 负载均衡"
proxy_group="$(cat $clashdir/proxy-groups.yaml $clashdir/config.yaml | sed "/#自定义策略组开始/,/#自定义策略组结束/d" | grep -Ev '^#' | grep -o '\- name:.*' | sed 's/#.*//' | sed 's/- name: /#/g' | tr -d '\n' | sed 's/#//')"
proxy_group="$(cat $clashdir/proxy-groups.yaml $clashdir/config.yaml 2>/dev/null| sed "/#自定义策略组开始/,/#自定义策略组结束/d" | grep -Ev '^#' | grep -o '\- name:.*' | sed 's/#.*//' | sed 's/- name: /#/g' | tr -d '\n' | sed 's/#//')"
set_group_type
setgroups
;;
@@ -488,13 +491,13 @@ setproxies(){
case $num in
1)
proxy_type="DOMAIN-SUFFIX DOMAIN-KEYWORD IP-CIDR SRC-IP-CIDR DST-PORT SRC-PORT GEOIP GEOSITE IP-CIDR6 DOMAIN MATCH"
proxy_group="$(cat $clashdir/proxy-groups.yaml $clashdir/config.yaml | sed "/#自定义策略组开始/,/#自定义策略组结束/d" | grep -Ev '^#' | grep -o '\- name:.*' | sed 's/#.*//' | sed 's/- name: /#/g' | tr -d '\n' | sed 's/#//')"
proxy_group="$(cat $clashdir/proxy-groups.yaml $clashdir/config.yaml 2>/dev/null | sed "/#自定义策略组开始/,/#自定义策略组结束/d" | grep -Ev '^#' | grep -o '\- name:.*' | sed 's/#.*//' | sed 's/- name: /#/g' | tr -d '\n' | sed 's/#//')"
set_proxy_type
setproxies
;;
2)
echo -----------------------------------------------
sed -i '/^ *$/d' $clashdir/proxies.yaml
sed -i '/^ *$/d' $clashdir/proxies.yaml 2>/dev/null
if [ -s $clashdir/proxies.yaml ];then
echo -e "当前已添加的自定义节点为:"
cat $clashdir/proxies.yaml | grep -Ev '^#' | awk -F '[,,}]' '{print NR, $1, $NF}' | sed 's/- {//g'
@@ -514,7 +517,7 @@ setproxies(){
;;
3)
read -p "确认清空全部自定义节点?(1/0) > " res
[ "$res" = "1" ] && sed -i '/^\s*[^#]/d' $clashdir/proxies.yaml
[ "$res" = "1" ] && sed -i '/^\s*[^#]/d' $clashdir/proxies.yaml 2>/dev/null
setproxies
;;
4)
@@ -726,7 +729,12 @@ clashlink(){
clashcron
;;
6)
checkcfg=$(cat $CFG_PATH)
override
if [ -n "$PID" ];then
checkcfg_new=$(cat $CFG_PATH)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
;;
*)
errornum
@@ -1296,6 +1304,12 @@ update(){
[ -z "$clash_v" ] && clash_v=$clashv
echo -e "\033[30;47m欢迎使用更新功能\033[0m"
echo -----------------------------------------------
echo -e "当前目录(\033[32m$clashdir\033[0m)剩余空间:\033[36m$(dir_avail $clashdir -h)\033[0m"
[ "$(dir_avail $clashdir)" -le 5120 ] && {
echo -e "\033[33m当前目录剩余空间较低建议开启小闪存模式\033[0m"
sleep 1
}
echo -----------------------------------------------
echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$versionsh$release_type\033[0m"
echo -e " 2 切换\033[33mclash核心 \033[33m$clash_v\033[0m > \033[32m$clash_n\033[0m"
echo -e " 3 更新\033[32mGeoIP/CN-IP \033[33m$Geo_v\033[0m > \033[32m$GeoIP_v\033[0m"

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) Juewuy
version=1.7.9e
version=1.7.9f
setdir(){
dir_avail(){

View File

@@ -375,6 +375,7 @@ modify_yaml(){
}
#插入自定义代理
sed -i "/#自定义代理/d" $tmpdir/proxies.yaml
sed -i "/#自定义代理/d" $tmpdir/proxy-groups.yaml
[ -n "$(grep -Ev '^#' $clashdir/proxies.yaml 2>/dev/null)" ] && {
space_proxy=$(cat $tmpdir/proxies.yaml | grep -E '^ *- ' | head -n 1 | grep -oE '^ *') #获取空格数
cat $clashdir/proxies.yaml | sed "s/^ *- /${space_proxy}- /g" | sed "/^#/d" | sed "/^ *$/d" | sed 's/#.*/ #自定义代理/g' >> $tmpdir/proxies.yaml #插入节点
@@ -1219,7 +1220,7 @@ bfstart(){
[ -z "$(grep 'procd_set_param user shellclash' /etc/init.d/clash)" ] && \
sed -i '/procd_close_instance/i\\t\tprocd_set_param user shellclash' /etc/init.d/clash
elif [ -w "$servdir" ]; then
setconfig ExecStart "/bin/su shellclash -c \"$bindir/clash -d $bindir\"" $servdir
setconfig ExecStart "/bin/su shellclash -c \"$bindir/clash -d $bindir >/dev/null\"" $servdir
systemctl daemon-reload >/dev/null
fi
fi