~自定义端口秘钥功能移回进阶配置菜单
~修复singbox自定义规则相关报错
~修复启动时提示找不到用户组的相关报错
~修复singbox内核部分启动失败的问题
~修复singbox内核启动时找不到配置文件的相关报错
This commit is contained in:
juewuy 2024-01-28 12:15:40 +08:00
parent bfccbb7e26
commit 21aba94e04
8 changed files with 45 additions and 65 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,5 +4,5 @@ clash_v=v1.7.1
meta_v=v1.18.0
singbox_v=1.7.8
versionsh=1.8.9
GeoIP_v=20240127
versionsh=1.8.9b

View File

@ -87,9 +87,9 @@ setrules(){ #自定义规则
}
echo -----------------------------------------------
echo -e "\033[33m你可以在这里快捷管理自定义规则\033[0m"
echo -e "\033[36m如需批量操作,请手动编辑:$YAMLSDIR/rules.yaml\033[0m"
echo -e "如需批量操作,请手动编辑:\033[36m $YAMLSDIR/rules.yaml\033[0m"
echo -e "\033[33msingbox和clash共用此处规则可无缝切换\033[0m"
echo -e "\033[36m大量规则请尽量使用rule-set功能添加此处过量添加可能导致启动卡顿\033[0m"
echo -e "大量规则请尽量使用rule-set功能添加\033[31m此处过量添加可能导致启动卡顿!\033[0m"
echo -----------------------------------------------
echo -e " 1 新增自定义规则"
echo -e " 2 移除自定义规则"
@ -366,13 +366,10 @@ EOF
set_singbox_adv(){ #自定义singbox配置文件
echo -----------------------------------------------
echo -e "singbox配置文件中支持自定义的模块有\033[0m"
echo -e "\033[32mlog dns ntp inbounds outbounds outbound_providers route experimental\033[0m"
echo -e "将相应json文件放入\033[32m$JSONSDIR\033[0m目录后即可在启动时加载"
echo -e "\033[31m注意自定义的log dns ntp experimental将完整替换内置设定而非增量合并\033[0m"
echo -e "singbox官方文档\033[36mhttps://sing-box.sagernet.org/zh/\033[0m"
echo -e "\033[36mlog dns ntp inbounds outbounds outbound_providers route experimental\033[0m"
echo -e "将相应json文件放入\033[33m$JSONSDIR\033[0m目录后即可在启动时加载"
echo -----------------------------------------------
echo -e "Windows下请\n使用\033[33mWinSCP软件\033[0m进行编辑\033[0m"
echo -e "MacOS下请\n使用\033[33mSecureFX软件\033[0m进行编辑\033[0m"
echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m"
}
override(){ #配置文件覆写
[ -z "$rule_link" ] && rule_link=1
@ -393,7 +390,6 @@ override(){ #配置文件覆写
read -p "请输入对应数字 > " num
case "$num" in
1)
source $CFG_PATH
if [ -n "$(pidof CrashCore)" ];then
echo -----------------------------------------------
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
@ -427,7 +423,7 @@ override(){ #配置文件覆写
9)
echo -----------------------------------------------
echo -e "\033[33m此功能可能会导致严重问题启用后脚本中大部分功能都将禁用\033[0m"
echo -e "如果你不是非常了解Clash的运行机制切勿开启\033[0m"
echo -e "如果你不是非常了解$crashcore的运行机制,切勿开启!\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
sleep 2

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) Juewuy
version=1.8.9
version=1.8.9b
setdir(){
dir_avail(){
@ -159,16 +159,9 @@ else
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
if [ -n "$sysdir" -a "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then
#创建shellcrash用户并赋予root权限
if type userdel useradd groupmod; then
userdel shellcrash 2>/dev/null
useradd shellcrash -u 7890 2>/dev/null
groupmod shellcrash -g 7890 2>/dev/null
sed -Ei s/7890:7890/0:7890/g /etc/passwd
else
sed -i '/0:7890/d' /etc/passwd
echo "shellcrash:x:0:7890::/home/shellcrash:/bin/sh" >> /etc/passwd
fi
#创建shellcrash用户
sed -i '/0:7890/d' /etc/passwd
echo "shellcrash:x:0:7890::/home/shellcrash:/bin/sh" >> /etc/passwd
#配置systemd
mv -f ${CRASHDIR}/shellcrash.service $sysdir/shellcrash.service 2>/dev/null
sed -i "s%/etc/ShellCrash%$CRASHDIR%g" $sysdir/shellcrash.service
@ -192,13 +185,13 @@ setconfig versionsh_l $version
touch ${CRASHDIR}/configs/command.env
setconfig TMPDIR ${TMPDIR} ${CRASHDIR}/configs/command.env
setconfig BINDIR ${BINDIR} ${CRASHDIR}/configs/command.env
if [ -x ${CRASHDIR}/CrashCore ] && [ -n "$(grep 'crashcore=singbox' ${CRASHDIR}/configs/ShellCrash.cfg)" ];then
COMMAND='"$BINDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"'
else
COMMAND='"$BINDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
fi
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env
}
if [ -x ${CRASHDIR}/CrashCore ] && [ -n "$(grep 'crashcore=singbox' ${CRASHDIR}/configs/ShellCrash.cfg)" ];then
COMMAND='"$BINDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"'
else
COMMAND='"$BINDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
fi
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env
#设置更新地址
[ -n "$url" ] && setconfig update_url $url
#设置环境变量

View File

@ -522,14 +522,14 @@ setdns(){ #DNS设置
[ -z "$dns_no" ] && dns_no=未禁用
echo -----------------------------------------------
echo -e "当前基础DNS\033[32m$dns_nameserver\033[0m"
echo -e "FallbackDNS\033[36m$dns_fallback\033[0m"
echo -e "PROXY-DNS\033[36m$dns_fallback\033[0m"
echo -e "多个DNS地址请用\033[30;47m“|”\033[0m或者\033[30;47m“, ”\033[0m分隔输入"
echo -e "\033[33m必须拥有本地根证书文件才能使用dot/doh类型的加密dns\033[0m"
echo -e "\033[33m注意singbox内核只有首个dns会被加载\033[0m"
echo -----------------------------------------------
echo -e " 1 修改\033[32m基础DNS\033[0m"
echo -e " 2 修改\033[36mFallback_DNS\033[0m"
echo -e " 3 \033[33m重置\033[0mDNS配置"
echo -e " 2 修改\033[36mPROXY-DNS\033[0m"
echo -e " 3 \033[33m重置\033[0m默认DNS配置"
echo -e " 4 一键配置\033[32m加密DNS\033[0m"
echo -e " 5 hosts优化 \033[36m$hosts_opt\033[0m ————调用本机hosts并劫持NTP服务"
echo -e " 6 Dnsmasq转发 \033[36m$dns_redir\033[0m ————不推荐使用"
@ -1441,7 +1441,7 @@ advanced_set(){ #进阶设置
echo -e " 3 配置公网及局域网防火墙"
[ "$disoverride" != "1" ] && {
echo -e " 4 启用域名嗅探: \033[36m$sniffer\033[0m ————用于流媒体及防DNS污染"
[ "$crashcore" = singbox ] || echo -e " 5 启用节点绕过: \033[36m$proxies_bypass\033[0m ————用于防止多设备多重流量"
echo -e " 5 自定义\033[32m端口及秘钥\033[0m"
echo -e " 6 配置内置DNS服务 \033[36m$dns_no\033[0m"
}
echo -----------------------------------------------
@ -1483,17 +1483,17 @@ advanced_set(){ #进阶设置
advanced_set
;;
5)
echo -----------------------------------------------
if [ "$proxies_bypass" = "未启用" ];then
proxies_bypass=已启用
echo -e "\033[33m仅当ShellCrash与子网络同类应用使用相同节点配置时方可生效\033[0m"
sleep 1
if [ -n "$(pidof CrashCore)" ];then
echo -----------------------------------------------
echo -e "\033[33m检测到服务正在运行需要先停止服务\033[0m"
read -p "是否停止服务?(1/0) > " res
if [ "$res" = "1" ];then
${CRASHDIR}/start.sh stop
setport
fi
else
proxies_bypass=未启用
fi
setconfig proxies_bypass $proxies_bypass
echo -e "\033[32m设置成功\033[0m"
sleep 1
setport
fi
advanced_set
;;
6)

View File

@ -529,8 +529,6 @@ EOF
done
}
modify_json(){ #修饰singbox配置文件
#准备目录
[ -d ${TMPDIR}/jsons ] && rm -rf ${TMPDIR}/jsons/* || mkdir -p ${TMPDIR}/jsons
#生成log.json
cat > ${TMPDIR}/jsons/log.json <<EOF
{ "log": { "level": "info", "timestamp": true } }
@ -699,7 +697,8 @@ EOF
#生成自定义规则文件
[ -s ${CRASHDIR}/yamls/rules.yaml ] && {
cat ${CRASHDIR}/yamls/rules.yaml \
| sed '/^#/d' \
| sed '/#.*/d' \
| grep -oE '\-.*,.*,.*' \
| sed 's/- DOMAIN-SUFFIX,/{ "domain_suffix": [ "/g' \
| sed 's/- DOMAIN-KEYWORD,/{ "domain_keyword": [ "/g' \
| sed 's/- IP-CIDR,/{ "ip_cidr": [ "/g' \
@ -750,12 +749,12 @@ EOF
#测试自定义配置文件
error=$(${BINDIR}/CrashCore check -D ${BINDIR} -C ${TMPDIR}/jsons 2>&1 | grep -Eo 'cust.*\.json' | sed 's/cust_//g' )
if [ -n "$error" ];then
[ "$error" = 'rules.json' ] && error=${CRASHDIR}/yamls/rules.yaml || error=${CRASHDIR}/jsons/$error
logger "自定义配置文件校验失败,请检查 $error 文件!" 31
[ "$error" = 'add_rules.json' ] && error_file=${CRASHDIR}/yamls/rules.yaml自定义规则 || error_file=${CRASHDIR}/jsons/$error
logger "自定义配置文件校验失败,请检查 ${error_file}文件!" 31
logger "尝试使用基础配置文件启动~" 33
#清理自定义配置文件并还原基础配置
rm -rf ${TMPDIR}/jsons/cust_*
mv -f ${TMPDIR}/jsons_base/* ${TMPDIR}/jsons
mv -f ${TMPDIR}/jsons_base/* ${TMPDIR}/jsons 2>/dev/null
fi
#清理缓存
rm -rf ${TMPDIR}/*.json
@ -1570,27 +1569,19 @@ bfstart(){ #启动前
#内核及内核配置文件检查
[ ! -x ${BINDIR}/CrashCore ] && chmod +x ${BINDIR}/CrashCore 2>/dev/null #检测可执行权限
if [ "$crashcore" = singbox ];then
singbox_check
[ "$disoverride" != "1" ] && modify_json || ln -sf $core_config ${TMPDIR}/config.json
singbox_check
[ -d ${TMPDIR}/jsons ] && rm -rf ${TMPDIR}/jsons/* || mkdir -p ${TMPDIR}/jsons #准备目录
[ "$disoverride" != "1" ] && modify_json || ln -sf $core_config ${TMPDIR}/jsons/config.json
else
clash_check
[ "$disoverride" != "1" ] && modify_yaml || ln -sf $core_config ${TMPDIR}/config.yaml
fi
#本机代理准备
if [ "$local_proxy" = "已开启" -a -n "$(echo $local_type | grep '增强模式')" ];then
#添加shellcrash用户
if [ -z "$(id shellcrash 2>/dev/null | grep 'root')" ];then
if ckcmd userdel useradd groupmod; then
userdel shellcrash 2>/dev/null
useradd shellcrash -u 7890
groupmod shellcrash -g 7890
sed -Ei s/7890:7890/0:7890/g /etc/passwd
else
sed -i '/0:7890/d' /etc/passwd
echo "shellcrash:x:0:7890:::" >> /etc/passwd
fi
fi
fi
#添加shellcrash用户
[ -n "$(echo $local_type | grep '增强模式')" -o "$(cat /proc/1/comm)" = "systemd" ] && \
[ -z "$(id shellcrash 2>/dev/null | grep 'root')" ] && {
sed -i '/0:7890/d' /etc/passwd
echo "shellcrash:x:0:7890::/home/shellcrash:/bin/sh" >> /etc/passwd
}
#清理debug日志
rm -rf ${TMPDIR}/debug.log
return 0