为适配singbox修改部分变量名及文本

This commit is contained in:
juewuy 2024-01-05 13:24:07 +08:00
parent 1f4deaa2e9
commit 7fc1fa20d8
4 changed files with 58 additions and 45 deletions

View File

@ -116,12 +116,12 @@ ckstatus(){
echo -e " 3 Clash.Meta内核"
read -p "请手动确定该内核类型 > " num
case "$num" in
2) clashcore=clashpre ;;
3) clashcore=meta ;;
*) clashcore=clash ;;
2) crashcore=clashpre ;;
3) crashcore=meta ;;
*) crashcore=clash ;;
esac
mv -f $file $bindir/clash && echo -e "\033[32m内核加载完成\033[0m " && sleep 1
setconfig clashcore $clashcore
setconfig crashcore $crashcore
}
else
echo -e "\033[33m检测到不可用的内核文件可能是文件受损或CPU架构不匹配\033[0m"
@ -1095,10 +1095,10 @@ clashcfg(){
set_redir_config(){
setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod
if [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && [ "$clashcore" = "clash" ];then
if [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && [ "$crashcore" = "clash" ];then
rm -rf $bindir/clash
rm -rf $CRASHDIR/clash
setconfig clashcore meta
setconfig crashcore meta
fi
echo -----------------------------------------------
echo -e "\033[36m已设为 $redir_mod \033[0m"
@ -1107,7 +1107,7 @@ clashcfg(){
[ -n "$(lsmod | grep '^tun')" ] || ip tuntap &>/dev/null && sup_tun=1
ckcmd nft && sup_nft=1
echo -----------------------------------------------
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0mClash核心为\033[47;30m $clashcore \033[0m"
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0mClash核心为\033[47;30m $crashcore \033[0m"
echo -e "\033[33m切换模式后需要手动重启服务以生效\033[0m"
echo -----------------------------------------------
echo -e " 1 \033[32mRedir模式\033[0m Redir转发TCP不转发UDP"
@ -1421,7 +1421,7 @@ clashadv(){
[ -z "$tproxy_mod" ] && tproxy_mod=未开启
[ -z "$public_support" ] && public_support=未开启
[ -z "$sniffer" ] && sniffer=未启用
[ "$clashcore" = "clashpre" ] && [ "$dns_mod" = "redir_host" ] && sniffer=已启用
[ "$crashcore" = "clashpre" ] && [ "$dns_mod" = "redir_host" ] && sniffer=已启用
[ "$bindir" = "/tmp/clash_$USER" ] && mini_clash=已开启 || mini_clash=未开启
#
echo -----------------------------------------------
@ -1457,14 +1457,14 @@ clashadv(){
4)
echo -----------------------------------------------
if [ "$sniffer" = "未启用" ];then
if [ "$clashcore" = "clash" ];then
if [ "$crashcore" = "clash" ];then
rm -rf $bindir/clash
clashcore=meta
setconfig clashcore $clashcore
crashcore=meta
setconfig crashcore $crashcore
echo "已将clash内核切换为Meta内核域名嗅探依赖Meta或者高版本clashpre内核"
fi
sniffer=已启用
elif [ "$clashcore" = "clashpre" -a "$dns_mod" = "redir_host" ];then
elif [ "$crashcore" = "clashpre" -a "$dns_mod" = "redir_host" ];then
echo -e "\033[31m使用clashpre内核且开启redir-host模式时无法关闭\033[0m"
else
sniffer=未启用

View File

@ -808,31 +808,35 @@ setcpucore(){
fi
}
getcore(){
[ -z "$clashcore" ] && clashcore=clashpre
[ -z "$crashcore" ] && crashcore=clashpre
[ -z "$cpucore" ] && getcpucore
#生成链接
[ -z "$custcorelink" ] && corelink="$update_url/bin/$clashcore/clash-linux-$cpucore" || corelink="$custcorelink"
#获取在线clash核心文件
[ -z "$custcorelink" ] && corelink="$update_url/bin/$crashcore/clash-linux-$cpucore" || corelink="$custcorelink"
#获取在线内核文件
echo -----------------------------------------------
echo 正在在线获取clash核心文件……
$CRASHDIR/start.sh webget $TMPDIR/clash.new $corelink
echo 正在在线获取$crashcore核心文件……
$CRASHDIR/start.sh webget $TMPDIR/core.new $corelink
if [ "$?" = "1" ];then
echo -e "\033[31m核心文件下载失败\033[0m"
rm -rf $TMPDIR/clash.new
rm -rf $TMPDIR/core.new
[ -z "$custcorelink" ] && error_down
else
chmod +x $TMPDIR/clash.new
chmod +x $TMPDIR/core.new
$CRASHDIR/start.sh stop
clashv=$($TMPDIR/clash.new -v 2>/dev/null | sed 's/ linux.*//;s/.* //')
if [ -z "$clashv" ];then
if [ "$crashcore" = singbox ];then
core_v=$($TMPDIR/core.new version 2>/dev/null | grep version | awk '{print $3}')
else
core_v=$($TMPDIR/core.new -v 2>/dev/null | sed 's/ linux.*//;s/.* //')
fi
if [ -z "$core_v" ];then
echo -e "\033[31m核心文件下载成功但校验失败请尝试手动指定CPU版本\033[0m"
rm -rf $TMPDIR/clash.new
rm -rf $TMPDIR/core.new
setcpucore
else
echo -e "\033[32m$clashcore核心下载成功\033[0m"
mv -f $TMPDIR/clash.new $bindir/clash
chmod +x $bindir/clash
setconfig clashcore $clashcore
echo -e "\033[32m$crashcore核心下载成功\033[0m"
mv -f $TMPDIR/core.new $bindir/CrashCore
chmod +x $bindir/CrashCore
setconfig crashcore $crashcore
fi
fi
}
@ -840,7 +844,7 @@ setcustcore(){
[ -z "$cpucore" ] && getcpucore
echo -----------------------------------------------
echo -e "\033[36m自定义内核均未经过适配可能存在部分功能不兼容的问题\033[0m"
echo -e "\033[36m如你不熟悉clash的运行机制,请使用脚本已经适配过的内核!\033[0m"
echo -e "\033[36m如你不熟悉相关内核的运行机制,请使用脚本已经适配过的内核!\033[0m"
echo -e "\033[36m自定义内核不兼容小闪存模式且下载可能依赖服务\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
@ -850,23 +854,29 @@ setcustcore(){
echo -e "\033[33m请选择需要使用的核心\033[0m"
echo -e "1 \033[32m 测试版ClashPre内核 \033[0m"
echo -e "2 \033[32m 最新Meta.Alpha内核 \033[0m"
echo -e "3 \033[33m 自定义内核链接 \033[0m"
echo -e "3 \033[32m Sing-Box官方内核 \033[0m"
echo -e "4 \033[33m 自定义内核链接 \033[0m"
read -p "请输入对应数字 > " num
case "$num" in
1)
clashcore=clashpre
crashcore=clashpre
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.premium.latest/clash-linux-$cpucore
getcore
;;
2)
clashcore=meta
crashcore=meta
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.meta.alpha/clash-linux-$cpucore
getcore
;;
3)
crashcore=singbox
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/singbox_core/singbox-linux-$cpucore
getcore
;;
4)
read -p "请输入自定义内核的链接地址(必须是二进制文件) > " link
[ -n "$link" ] && custcorelink="$link"
clashcore=meta
crashcore=meta
getcore
;;
*)
@ -877,11 +887,11 @@ setcustcore(){
}
setcore(){
#获取核心及版本信息
[ ! -f $CRASHDIR/clash ] && clashcore="未安装核心"
[ ! -f $CRASHDIR/CrashCore ] && crashcore="未安装核心"
###
echo -----------------------------------------------
[ -z "$cpucore" ] && getcpucore
echo -e "当前clash核心\033[42;30m $clashcore \033[47;30m$clashv\033[0m"
echo -e "当前clash核心\033[42;30m $crashcore \033[47;30m$clashv\033[0m"
echo -e "当前系统处理器架构:\033[32m $cpucore \033[0m"
echo -e "\033[33m请选择需要使用的核心版本\033[0m"
echo -----------------------------------------------
@ -905,17 +915,17 @@ setcore(){
read -p "请输入对应数字 > " num
case "$num" in
1)
clashcore=clash
crashcore=clash
custcorelink=''
getcore
;;
2)
clashcore=clashpre
crashcore=clashpre
custcorelink=''
getcore
;;
3)
clashcore=meta
crashcore=meta
custcorelink=''
getcore
;;
@ -1002,7 +1012,7 @@ setgeo(){
fi
setgeo
elif [ "$num" = '5' ]; then
if [ "$clashcore" = "meta" ]; then
if [ "$crashcore" = "meta" ]; then
geotype=geosite.dat
geoname=GeoSite.dat
getgeo
@ -1298,9 +1308,9 @@ update(){
echo -----------------------------------------------
echo -ne "\033[32m正在检查更新\033[0m\r"
checkupdate
clash_v=$($bindir/clash -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
[ -z "$clash_v" ] && clash_v=$clashv
clash_v_new=$(eval echo \$${clashcore}_v)
core_v=$($bindir/clash -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
[ -z "$core_v" ] && core_v=$clashv
core_v_new=$(eval echo \$${crashcore}_v)
echo -e "\033[30;47m欢迎使用更新功能\033[0m"
echo -----------------------------------------------
echo -e "当前目录(\033[32m$CRASHDIR\033[0m)剩余空间:\033[36m$(dir_avail $CRASHDIR -h)\033[0m"
@ -1310,7 +1320,7 @@ update(){
}
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_v_new\033[0m"
echo -e " 2 切换\033[33m内核文件 \033[33m$core_v\033[0m > \033[32m$core_v_new\033[0m"
echo -e " 3 更新\033[32m数据库文件\033[0m"
echo -e " 4 安装本地\033[35mDashboard\033[0m面板"
echo -e " 5 安装/更新本地\033[33m根证书文件\033[0m"
@ -1431,7 +1441,7 @@ userguide(){
fi
elif [ "$num" = 2 ];then
setconfig redir_mod "纯净模式"
setconfig clashcore "clash"
setconfig crashcore "clash"
setconfig common_ports "未开启"
echo -----------------------------------------------
echo -e "\033[36m请选择设置本机代理的方式\033[0m"

View File

@ -247,6 +247,8 @@ done
#配置文件改名
mv -f $CRASHDIR/mark $CRASHDIR/configs/ShellCrash.cfg 2>/dev/null
mv -f $CRASHDIR/configs/ShellClash.cfg $CRASHDIR/configs/ShellCrash.cfg 2>/dev/null
#内核改名
mv -f $CRASHDIR/clash $CRASHDIR/CrashCore 2>/dev/null
for file in dropbear_rsa_host_key authorized_keys tun.ko ShellDDNS.sh;do
mv -f $CRASHDIR/$file $CRASHDIR/tools/$file 2>/dev/null
done
@ -257,6 +259,7 @@ chmod 755 $CRASHDIR/task/task.sh
for file in log clash.service mark? mark.bak;do
rm -rf $CRASHDIR/$file
done
#旧版任务清理
$CRASHDIR/start.sh cronset "clash服务" 2>/dev/null
$CRASHDIR/start.sh cronset "订阅链接" 2>/dev/null

View File

@ -25,14 +25,14 @@ check_update(){ #检查更新工具
update_core(){ #自动更新内核
#检查版本
check_update
clash_v_new=$(eval echo \$${clashcore}_v)
clash_v_new=$(eval echo \$${crashcore}_v)
clash_v_now=$($bindir/clash -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
if [ -z "$clash_v_new" -o "$clash_v_new" = "clash_v_now" ];then
logger "任务【自动更新内核】中止-未检测到版本更新"
exit 1
else
#更新内核
$CRASHDIR/start.sh webget $TMPDIR/clash.new "$update_url/bin/$clashcore/clash-linux-$cpucore"
$CRASHDIR/start.sh webget $TMPDIR/clash.new "$update_url/bin/$crashcore/clash-linux-$cpucore"
if [ "$?" != "0" ];then
logger "任务【自动更新内核】出错-下载失败!"
rm -rf $TMPDIR/clash.new
@ -44,7 +44,7 @@ update_core(){ #自动更新内核
if [ -z "$clashv" ];then
logger "任务【自动更新内核】出错-下载失败!"
rm -rf $TMPDIR/clash.new
[ $clashcore = meta ] && $CRASHDIR/start.sh start
[ $crashcore = meta ] && $CRASHDIR/start.sh start
return 1
else
mv -f $TMPDIR/clash.new $bindir/clash