~更新功能调整,新增更新版本通道选择
  ·增加稳定版分支及分支切换
  ·增加公测版及开发版分支
  ·现在前4个源都支持各个分支之间任意切换及回退
  ·内测源今后改为个人开发测试用,请更新后尽快换源
~正式适配sing-box1.8.0内核
  ·已编译mips相关版本内核文件
  ·已将内核添加到项目内/bin目录,以支持小闪存模式
  ·编译时移除了with_gvisor参数,以优化内存占用
~修复手动加载/tmp目录下内核时无法正确识别的bug
~修复保守模式启用本机代理后部分设备导致日志刷屏的bug
This commit is contained in:
juewuy
2024-01-12 21:36:31 +08:00
parent 3679267902
commit 75f1bbeaa4
10 changed files with 184 additions and 125 deletions

View File

@@ -9,7 +9,7 @@ source ${CRASHDIR}/configs/command.env &>/dev/null
[ -z "$BINDIR" -o -z "$TMPDIR" -o -z "$COMMAND" ] && source ${CRASHDIR}/init.sh &>/dev/null
[ ! -f ${TMPDIR} ] && mkdir -p ${TMPDIR}
#读取配置相关
#脚本内部工具
setconfig(){
#参数1代表变量名参数2代表变量值,参数3即文件路径
[ -z "$3" ] && configpath=${CFG_PATH} || configpath="${3}"
@@ -18,7 +18,9 @@ setconfig(){
ckcmd(){
command -v sh &>/dev/null && command -v $1 &>/dev/null || type $1 &>/dev/null
}
ckstatus(){
#脚本启动前检查
ckstatus(){
#检查/读取脚本配置文件
if [ -f $CFG_PATH ];then
[ -n "$(awk 'a[$0]++' $CFG_PATH)" ] && awk '!a[$0]++' $CFG_PATH > $CFG_PATH #检查重复行并去除
@@ -28,8 +30,6 @@ ckstatus(){
fi
versionsh=$(cat ${CRASHDIR}/init.sh | grep -E ^version= | head -n 1 | sed 's/version=//')
[ -n "$versionsh" ] && versionsh_l=$versionsh
#服务器缺省地址
[ -z "$update_url" ] && update_url=https://fastly.jsdelivr.net/gh/juewuy/ShellCrash
#设置默认端口及变量
[ -z "$mix_port" ] && mix_port=7890
[ -z "$redir_port" ] && redir_port=7892
@@ -101,15 +101,15 @@ ckstatus(){
#检查执行权限
[ ! -x ${CRASHDIR}/start.sh ] && chmod +x ${CRASHDIR}/start.sh
#检查/tmp内核文件
for file in `ls -F /tmp | grep -v [/\$] | grep -v '\ ' | grep -Ev ".*[(gz)(zip)(7z)(tar)(xz)]$" | grep -iE '^clash$|^clash-linux.*|^mihomo.*|^sing.*box|^clash.meta.*'` ; do
for file in `ls -F /tmp | grep -v [/\$] | grep -v '\ ' | grep -Ev ".*[(gz)(zip)(7z)(tar)]$" | grep -iE '^clash$|^clash-linux.*|^mihomo.*|^sing.*box|^clash.meta.*'` ; do
file=/tmp/$file
chmod +x $file
echo -e "发现可用的内核文件: \033[36m$file\033[0m "
read -p "是否加载(会停止当前服务)(1/0) > " res
[ "$res" = 1 ] && {
${CRASHDIR}/start.sh stop
core_v=$($file -v &>/dev/null)
[ -z "$core_v" ] && $($file version &>/dev/null)
core_v=$($file -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
[ -z "$core_v" ] && core_v=$($file version 2>/dev/null | grep -Eo 'version .*' | sed 's/version //')
if [ -n "$core_v" ];then
source ${CRASHDIR}/getdate.sh && setcoretype && \
mv -f $file ${CRASHDIR}/CrashCore && \
@@ -151,8 +151,7 @@ ckstatus(){
echo -----------------------------------------------
}
}
#启动相关
#内核服务启动相关
errornum(){
echo -----------------------------------------------
echo -e "\033[31m请输入正确的字母或数字\033[0m"
@@ -394,7 +393,7 @@ log_pusher(){ #日志菜单
*) errornum ;;
esac
}
setport(){
setport(){ #端口设置
source $CFG_PATH > /dev/null
[ -z "$secret" ] && secret=未设置
[ -z "$authentication" ] && auth=未设置 || auth=******
@@ -514,7 +513,7 @@ setport(){
setport
fi
}
setdns(){
setdns(){ #DNS设置
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
[ -z "$hosts_opt" ] && hosts_opt=已开启
@@ -627,7 +626,7 @@ setdns(){
setdns
fi
}
setipv6(){
setipv6(){ #ipv6设置
[ -z "$ipv6_support" ] && ipv6_support=已开启
[ -z "$ipv6_redir" ] && ipv6_redir=未开启
@@ -687,7 +686,7 @@ setipv6(){
;;
esac
}
setfirewall(){
setfirewall(){ #防火墙设置
set_cust_host_ipv4(){
echo -----------------------------------------------
echo -e "当前已自动设置透明路由的网段为: \033[32m$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'br' | grep -v 'iot' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ' && echo ) \033[0m"
@@ -763,7 +762,7 @@ setfirewall(){
;;
esac
}
checkport(){
checkport(){ #自动检查端口冲突
for portx in $dns_port $mix_port $redir_port $db_port ;do
if [ -n "$(netstat -ntul 2>&1 |grep '\:$portx ')" ];then
echo -----------------------------------------------
@@ -777,7 +776,7 @@ checkport(){
fi
done
}
macfilter(){
macfilter(){ #局域网设备过滤
add_mac(){
echo -----------------------------------------------
echo 已添加的mac地址
@@ -908,7 +907,7 @@ macfilter(){
macfilter
fi
}
localproxy(){
localproxy(){ #本机代理
[ -w /etc/systemd/system/shellcrash.service -o -w /usr/lib/systemd/system/shellcrash.service -o -x /bin/su ] && local_enh=1
[ -f /etc/rc.common -a -w /etc/passwd ] && local_enh=1
echo -----------------------------------------------
@@ -949,7 +948,7 @@ localproxy(){
setconfig local_proxy $local_proxy
setconfig local_type $local_type
}
setboot(){
setboot(){ #启动相关设置
[ -z "$start_old" ] && start_old=未开启
[ -z "$start_delay" -o "$start_delay" = 0 ] && delay=未设置 || delay=${start_delay}
[ "$autostart" = "enable" ] && auto_set="\033[33m禁止" || auto_set="\033[32m允许"
@@ -1096,7 +1095,7 @@ metacfg(){
echo -----------------------------------------------
}
normal_set(){
normal_set(){ #基础设置
set_redir_mod(){
set_redir_config(){
setconfig redir_mod $redir_mod
@@ -1423,7 +1422,7 @@ normal_set(){
errornum
fi
}
advanced_set(){
advanced_set(){ #进阶设置
#获取设置默认显示
[ -z "$proxies_bypass" ] && proxies_bypass=未启用
[ -z "$start_old" ] && start_old=未开启
@@ -1535,7 +1534,7 @@ advanced_set(){
*) errornum ;;
esac
}
#工具脚本
#工具列表
autoSSH(){
echo -----------------------------------------------
echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m"
@@ -1668,7 +1667,7 @@ tools(){
echo -----------------------------------------------
if [ ! -f ${CRASHDIR}/tools/ShellDDNS.sh ];then
echo -e "正在获取在线脚本……"
${CRASHDIR}/start.sh webget ${TMPDIR}/ShellDDNS.sh $update_url/tools/ShellDDNS.sh
${CRASHDIR}/start.sh get_bin ${TMPDIR}/ShellDDNS.sh tools/ShellDDNS.sh
if [ "$?" = "0" ];then
mv -f ${TMPDIR}/ShellDDNS.sh ${CRASHDIR}/tools/ShellDDNS.sh
source ${CRASHDIR}/tools/ShellDDNS.sh
@@ -1708,10 +1707,9 @@ tools(){
sleep 1
read -p "我已知晓,出现问题会自行承担!(1/0) > " res
if [ "$res" = 1 ];then
tunfixlink="${update_url}/bin/fix/tun.ko"
echo -----------------------------------------------
echo 正在连接服务器获取Tun模块补丁文件…………
${CRASHDIR}/start.sh webget ${TMPDIR}/tun.ko $tunfixlink
${CRASHDIR}/start.sh get_bin ${TMPDIR}/tun.ko bin/fix/tun.ko
if [ "$?" = "0" ];then
mv -f ${TMPDIR}/tun.ko ${CRASHDIR}/tools/tun.ko && \
${CRASHDIR}/misnap_init.sh tunfix && \