~重新启用内核启动后会自动清理缓存文件的功能

~修复pre5版本因为内核缓存被清理产生的报错
~现在使用providers生成配置文件后,会自动禁用定时更新配置功能
~修复因链接包含特殊字符导致providers链接修改出错的问题
~修复脚本安装或升级时的部分错误提示
~singbox现在会自动补全配置文件中缺少的DIRECT及REJECT出口字段
~修复因为设置了面板访问密码导致节点还原失败的bug
~cnip绕过文件调整为启动前下载而不是启动成功后
~部分文字说明调整
This commit is contained in:
juewuy 2024-02-13 21:43:44 +08:00
parent 64b9e62a73
commit 06ddd9968e
5 changed files with 34 additions and 26 deletions

View File

@ -390,16 +390,17 @@ EOF
cut -c 1- ${TMPDIR}/providers/providers.yaml ${TMPDIR}/providers/proxy-groups.yaml ${TMPDIR}/providers/rules.yaml > ${TMPDIR}/config.yaml cut -c 1- ${TMPDIR}/providers/providers.yaml ${TMPDIR}/providers/proxy-groups.yaml ${TMPDIR}/providers/rules.yaml > ${TMPDIR}/config.yaml
rm -rf ${TMPDIR}/providers rm -rf ${TMPDIR}/providers
#调用内核测试 #调用内核测试
${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml >/dev/null ${CRASHDIR}/start.sh core_check && ${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml >/dev/null
if [ "$?" = 0 ];then if [ "$?" = 0 ];then
echo -e "\033[32m配置文件生成成功\033[0m" echo -e "\033[32m配置文件生成成功\033[0m"
mv -f ${TMPDIR}/config.yaml ${CRASHDIR}/yamls/config.yaml mv -f ${TMPDIR}/config.yaml ${CRASHDIR}/yamls/config.yaml
read -p "是否立即启动/重启服务?(1/0) > " res read -p "是否立即启动/重启服务?(1/0) > " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
start_core start_core && $CRASHDIR/start.sh cronset '更新订阅'
exit exit
} }
else else
rm -rf ${TMPDIR}/CrashCore
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m" echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m"
fi fi
} }
@ -463,24 +464,26 @@ EOF
#使用模版生成outbounds和rules模块 #使用模版生成outbounds和rules模块
cat ${CRASHDIR}/providers/${provider_temp_file} | sed "s/{providers_tags}/$providers_tags/g" >> ${TMPDIR}/providers/outbounds.json cat ${CRASHDIR}/providers/${provider_temp_file} | sed "s/{providers_tags}/$providers_tags/g" >> ${TMPDIR}/providers/outbounds.json
#调用内核测试 #调用内核测试
${TMPDIR}/CrashCore merge ${TMPDIR}/config.json -C ${TMPDIR}/providers ${CRASHDIR}/start.sh core_check && ${TMPDIR}/CrashCore merge ${TMPDIR}/config.json -C ${TMPDIR}/providers
if [ "$?" = 0 ];then if [ "$?" = 0 ];then
echo -e "\033[32m配置文件生成成功\033[0m" echo -e "\033[32m配置文件生成成功\033[0m"
mv -f ${TMPDIR}/config.json ${CRASHDIR}/jsons/config.json mv -f ${TMPDIR}/config.json ${CRASHDIR}/jsons/config.json
rm -rf ${TMPDIR}/providers rm -rf ${TMPDIR}/providers
read -p "是否立即启动/重启服务?(1/0) > " res read -p "是否立即启动/重启服务?(1/0) > " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
start_core start_core && $CRASHDIR/start.sh cronset '更新订阅'
exit exit
} }
else else
echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m" echo -e "\033[31m生成配置文件出错请仔细检查输入\033[0m"
rm -rf ${TMPDIR}/CrashCore
rm -rf ${TMPDIR}/providers rm -rf ${TMPDIR}/providers
fi fi
} }
setproviders(){ #自定义providers setproviders(){ #自定义providers
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers提供者\033[0m" echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers提供者\033[0m"
echo -e "\033[33m暂时只支持yaml格式的配置导入\033[0m"
[ -s $CRASHDIR/configs/providers.cfg ] && { [ -s $CRASHDIR/configs/providers.cfg ] && {
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[36m输入对应数字可管理providers提供者\033[0m" echo -e "\033[36m输入对应数字可管理providers提供者\033[0m"
@ -524,6 +527,7 @@ setproviders(){ #自定义providers
2) 2)
read -p "请输入http(s)格式的providers链接地址 > " link read -p "请输入http(s)格式的providers链接地址 > " link
if [ -n "$(echo $link | grep -E '.*\..*')" ] && [ -z "$(grep "$link" $CRASHDIR/configs/providers.cfg)" ];then if [ -n "$(echo $link | grep -E '.*\..*')" ] && [ -z "$(grep "$link" $CRASHDIR/configs/providers.cfg)" ];then
link=$(echo $link | sed 's/\&/\\\&/g') #特殊字符添加转义
sed -i "s|$provider_name $provider_url|$provider_name $link|" $CRASHDIR/configs/providers.cfg sed -i "s|$provider_name $provider_url|$provider_name $link|" $CRASHDIR/configs/providers.cfg
else else
echo -e "\033[31m输入错误请重新输入\033[0m" echo -e "\033[31m输入错误请重新输入\033[0m"
@ -1003,7 +1007,7 @@ set_core_config(){ #配置文件功能
exit exit
;; ;;
5) 5)
source ${CRASHDIR}/task/task.sh && task_add source ${CRASHDIR}/task/task.sh && task_menu
set_core_config set_core_config
;; ;;
6) 6)
@ -1676,7 +1680,7 @@ setgeo(){ #数据库选择菜单
rm -rf $CRASHDIR/$file rm -rf $CRASHDIR/$file
done done
rm -rf $CRASHDIR/*.srs rm -rf $CRASHDIR/*.srs
echo -e "\033[33m所数据库文件均已清理!\033[0m" echo -e "\033[33m所数据库文件均已清理!\033[0m"
sleep 1 sleep 1
} }
setgeo setgeo
@ -2285,6 +2289,7 @@ debug(){
else else
${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml ${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml
fi fi
rm -rf ${TMPDIR}/CrashCore
echo ----------------------------------------------- echo -----------------------------------------------
exit exit
;; ;;
@ -2292,6 +2297,7 @@ debug(){
$CRASHDIR/start.sh stop $CRASHDIR/start.sh stop
$CRASHDIR/start.sh bfstart $CRASHDIR/start.sh bfstart
$COMMAND $COMMAND
rm -rf ${TMPDIR}/CrashCore
echo ----------------------------------------------- echo -----------------------------------------------
exit exit
;; ;;
@ -2318,7 +2324,8 @@ debug(){
main_menu main_menu
;; ;;
9) 9)
$TMPDIR/CrashCore merge $TMPDIR/debug.json -C $TMPDIR/jsons && echo -e "\033[32m合并成功\033[0m" ${CRASHDIR}/start.sh core_check && $TMPDIR/CrashCore merge $TMPDIR/debug.json -C $TMPDIR/jsons && echo -e "\033[32m合并成功\033[0m"
rm -rf ${TMPDIR}/CrashCore
main_menu main_menu
;; ;;
*) *)

View File

@ -160,7 +160,7 @@ else
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system [ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
if [ -n "$sysdir" -a "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then if [ -n "$sysdir" -a "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then
#创建shellcrash用户 #创建shellcrash用户
ckcmd userdel && userdel shellcrash 2>/dev/null type userdel && userdel shellcrash 2>/dev/null
sed -i '/0:7890/d' /etc/passwd sed -i '/0:7890/d' /etc/passwd
sed -i '/x:7890/d' /etc/group sed -i '/x:7890/d' /etc/group
if type useradd >/dev/null 2>&1; then if type useradd >/dev/null 2>&1; then
@ -217,12 +217,12 @@ if [ -n "$profile" ];then
source $profile >/dev/null 2>&1 || echo 运行错误请使用bash而不是dash运行安装命令 source $profile >/dev/null 2>&1 || echo 运行错误请使用bash而不是dash运行安装命令
#适配zsh环境变量 #适配zsh环境变量
[ -n "$(cat /etc/shells 2>/dev/null|grep -oE 'zsh')" ] && [ -z "$(cat ~/.zshrc 2>/dev/null|grep CRASHDIR)" ] && { [ -n "$(cat /etc/shells 2>/dev/null|grep -oE 'zsh')" ] && [ -z "$(cat ~/.zshrc 2>/dev/null|grep CRASHDIR)" ] && {
sed -i '/alias crash=*/'d ~/.zshrc sed -i '/alias crash=*/'d ~/.zshrc 2>/dev/null
echo "alias crash=\"$shtype $CRASHDIR/menu.sh\"" >> ~/.zshrc echo "alias crash=\"$shtype $CRASHDIR/menu.sh\"" >> ~/.zshrc
# 兼容 clash 命令 # 兼容 clash 命令
sed -i '/alias clash=*/'d ~/.zshrc sed -i '/alias clash=*/'d ~/.zshrc 2>/dev/null
echo "alias clash=\"$shtype $CRASHDIR/menu.sh\"" >> ~/.zshrc echo "alias clash=\"$shtype $CRASHDIR/menu.sh\"" >> ~/.zshrc
sed -i '/export CRASHDIR=*/'d ~/.zshrc sed -i '/export CRASHDIR=*/'d ~/.zshrc 2>/dev/null
echo "export CRASHDIR=\"$CRASHDIR\"" >> ~/.zshrc echo "export CRASHDIR=\"$CRASHDIR\"" >> ~/.zshrc
source ~/.zshrc >/dev/null 2>&1 source ~/.zshrc >/dev/null 2>&1
} }

View File

@ -166,6 +166,7 @@ startover(){
echo -e "其他设备可以使用PAC配置连接\033[4;32mhttp://$host:$db_port/ui/pac\033[0m" echo -e "其他设备可以使用PAC配置连接\033[4;32mhttp://$host:$db_port/ui/pac\033[0m"
echo -e "或者使用HTTP/SOCK5方式连接IP{\033[36m$host\033[0m}端口{\033[36m$mix_port\033[0m}" echo -e "或者使用HTTP/SOCK5方式连接IP{\033[36m$host\033[0m}端口{\033[36m$mix_port\033[0m}"
fi fi
return 0
} }
start_core(){ start_core(){
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then

View File

@ -730,10 +730,14 @@ EOF
EOF EOF
fi fi
#生成add_outbounds.json #生成add_outbounds.json
[ -z "$(cat ${CRASHDIR}/jsons/*.json | grep -oE '"tag": *"DIRECT"')" ] && cat > ${TMPDIR}/jsons/add_outbounds.json <<EOF [ -z "$(cat ${CRASHDIR}/jsons/*.json | grep -oE '"tag" *: *"DIRECT"')" ] && add_direct='{ "type": "direct", "tag": "DIRECT" }'
[ -z "$(cat ${CRASHDIR}/jsons/*.json | grep -oE '"tag" *: *"REJECT"')" ] && add_reject='{ "type": "block", "tag": "REJECT" }'
[ -n "$add_direct" -a -n "$add_reject" ] && add_direct="${add_direct},"
[ -n "$add_direct" -o -n "$add_reject" ] && cat > ${TMPDIR}/jsons/add_outbounds.json <<EOF
{ {
"outbounds": [ "outbounds": [
{ "type": "direct", "tag": "DIRECT" } $add_direct
$add_reject
] ]
} }
EOF EOF
@ -1426,11 +1430,7 @@ web_restore(){ #还原面板选择
i=1 i=1
while [ -z "$test" -a "$i" -lt 20 ];do while [ -z "$test" -a "$i" -lt 20 ];do
sleep 2 sleep 2
if curl --version > /dev/null 2>&1;then test=$(get_save http://127.0.0.1:${db_port}/configs | grep -o port)
test=$(curl -s http://127.0.0.1:${db_port}/configs | grep -o port)
else
test=$(wget -q -O - http://127.0.0.1:${db_port}/configs | grep -o port)
fi
i=$((i+1)) i=$((i+1))
done done
[ -n "$test" ] && { [ -n "$test" ] && {
@ -1465,11 +1465,11 @@ makehtml(){ #生成面板跳转文件
<div style="text-align: center; margin-top: 50px;"> <div style="text-align: center; margin-top: 50px;">
<h1>您还未安装本地面板</h1> <h1>您还未安装本地面板</h1>
<h3>请在脚本更新功能中(9-4)安装<br>或者使用在线面板:</h3> <h3>请在脚本更新功能中(9-4)安装<br>或者使用在线面板:</h3>
<h4>请复制当前地址/ui(不包括)前面的内容填入url位置即可连接</h3>
<a href="https://metacubexd.pages.dev" style="font-size: 24px;">Meta XD面板(推荐)<br></a> <a href="https://metacubexd.pages.dev" style="font-size: 24px;">Meta XD面板(推荐)<br></a>
<a href="https://yacd.metacubex.one" style="font-size: 24px;">Meta YACD面板(推荐)<br></a> <a href="https://yacd.metacubex.one" style="font-size: 24px;">Meta YACD面板(推荐)<br></a>
<a href="https://yacd.haishan.me" style="font-size: 24px;">Clash YACD面板<br></a> <a href="https://yacd.haishan.me" style="font-size: 24px;">Clash YACD面板<br></a>
<a href="https://clash.razord.top" style="font-size: 24px;">Clash Razord面板<br></a> <a style="font-size: 18px;"><br>如已安装请使用Ctrl+F5强制刷新<br></a>
<a style="font-size: 16px;"><br>如已安装请使用Ctrl+F5强制刷新<br></a>
</div> </div>
</body> </body>
</html </html
@ -1591,9 +1591,9 @@ singbox_check(){ #singbox启动前检查
fi fi
core_check core_check
#预下载geoip-cn.srs数据库 #预下载geoip-cn.srs数据库
[ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"rule_set": *"geoip-cn"')" ] && ckgeo geoip-cn.srs srs_geoip_cn.srs [ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"rule_set" *: *"geoip-cn"')" ] && ckgeo geoip-cn.srs srs_geoip_cn.srs
#预下载geosite-cn.srs数据库 #预下载geosite-cn.srs数据库
[ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"rule_set": *"geosite-cn"')" -o "$dns_mod" = "mix" ] && ckgeo geosite-cn.srs srs_geosite_cn.srs [ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"rule_set" *: *"geosite-cn"')" -o "$dns_mod" = "mix" ] && ckgeo geosite-cn.srs srs_geosite_cn.srs
#预下载GeoIP数据库 #预下载GeoIP数据库
[ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"geoip":')" ] && ckgeo geoip.db geoip_cn.db [ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"geoip":')" ] && ckgeo geoip.db geoip_cn.db
#预下载GeoSite数据库 #预下载GeoSite数据库
@ -1633,6 +1633,9 @@ bfstart(){ #启动前
clash_check clash_check
[ "$disoverride" != "1" ] && modify_yaml || ln -sf $core_config ${TMPDIR}/config.yaml [ "$disoverride" != "1" ] && modify_yaml || ln -sf $core_config ${TMPDIR}/config.yaml
fi fi
#检查下载cnip绕过相关文件
[ "$dns_mod" != "fake-ip" ] && [ "$cn_ip_route" = "已开启" ] && cn_ip_route
[ "$ipv6_redir" = "已开启" ] && [ "$dns_mod" != "fake-ip" ] && [ "$cn_ipv6_route" = "已开启" ] && cn_ipv6_route
#添加shellcrash用户 #添加shellcrash用户
[ -n "$(echo $local_type | grep '增强模式')" -o "$(cat /proc/1/comm)" = "systemd" ] && \ [ -n "$(echo $local_type | grep '增强模式')" -o "$(cat /proc/1/comm)" = "systemd" ] && \
[ -z "$(id shellcrash 2>/dev/null | grep 'root')" ] && { [ -z "$(id shellcrash 2>/dev/null | grep 'root')" ] && {
@ -1672,11 +1675,9 @@ afstart(){ #启动后
i=$((i+1)) i=$((i+1))
done done
if [ -n "$test" -o -n "$(pidof CrashCore)" ];then if [ -n "$test" -o -n "$(pidof CrashCore)" ];then
#rm -rf ${TMPDIR}/CrashCore #删除缓存目录内核文件 rm -rf ${TMPDIR}/CrashCore #删除缓存目录内核文件
#设置DNS转发 #设置DNS转发
start_dns(){ start_dns(){
[ "$dns_mod" != "fake-ip" ] && [ "$cn_ip_route" = "已开启" ] && cn_ip_route
[ "$ipv6_redir" = "已开启" ] && [ "$dns_mod" != "fake-ip" ] && [ "$cn_ipv6_route" = "已开启" ] && cn_ipv6_route
if [ "$dns_no" != "已禁用" ];then if [ "$dns_no" != "已禁用" ];then
if [ "$dns_redir" != "已开启" ];then if [ "$dns_redir" != "已开启" ];then
[ -n "$(echo $redir_mod|grep Nft)" ] && start_nft_dns || start_ipt_dns [ -n "$(echo $redir_mod|grep Nft)" ] && start_nft_dns || start_ipt_dns

View File

@ -152,7 +152,6 @@ ntp(){
[ "$crashcore" != singbox ] && ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0 & [ "$crashcore" != singbox ] && ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0 &
} }
#任务工具 #任务工具
logger(){ logger(){
[ "$task_push" = 1 ] && push= || push=off [ "$task_push" = 1 ] && push= || push=off
[ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m" [ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m"