Skip to content

Commit 32b1b07

Browse files
committed
优化 Windows 端裸核运行 bash 脚本
1 parent abfa51f commit 32b1b07

2 files changed

Lines changed: 94 additions & 98 deletions

File tree

_posts/2024-08-22-share-windows-singboxr-ruleset.md

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -523,63 +523,61 @@ Windows Registry Editor Version 5.00
523523

524524
echo "导入(更新)sing-boxr 配置文件"
525525
cd "$PROGRAMFILES"
526-
if [ -f "./sing-box/sing-box.exe" ]; then
527-
if [ -f "./sing-box/config.json" ]; then
528-
echo "检测到 sing-boxr 配置文件,是否更新?(Y/n)"
529-
while true; do
530-
read -n1 -r choice
531-
case $choice in
532-
[Yy])
533-
echo
534-
echo "正在下载 sing-boxr 配置文件..."
535-
curl -sS -o "$USERPROFILE/Downloads/config.json" -L https://ghfast.top/{.json 配置文件直链}
536-
echo "下载 sing-boxr 配置文件成功"
537-
538-
echo "正在结束 sing-boxr 相关进程..."
539-
taskkill //f //t //im "sing-box*"
540-
echo "结束 sing-boxr 相关进程成功"
541-
542-
echo "正在更新 sing-boxr 配置文件..."
543-
mv -f "$USERPROFILE/Downloads/config.json" ./sing-box
544-
echo "更新 sing-boxr 配置文件成功,是否启动服务?(Y/n)"
545-
ask_run
546-
break
547-
;;
548-
[Nn])
549-
break
550-
;;
551-
*)
552-
echo
553-
echo "无效选择,请重新输入!"
554-
;;
555-
esac
556-
done
557-
else
558-
echo "未检测到 sing-boxr 配置文件,是否导入?(Y/n)"
559-
while true; do
560-
read -n1 -r choice
561-
case $choice in
562-
[Yy])
563-
echo
564-
echo "正在导入 sing-boxr 配置文件..."
565-
curl -sS -o "$USERPROFILE/Downloads/config.json" -L https://ghfast.top/{.json 配置文件直链}
566-
mv -f "$USERPROFILE/Downloads/config.json" ./sing-box
567-
echo "导入 sing-boxr 配置文件成功,是否启动服务?(Y/n)"
568-
ask_run
569-
break
570-
;;
571-
[Nn])
572-
break
573-
;;
574-
*)
575-
echo
576-
echo "无效选择,请重新输入!"
577-
;;
578-
esac
579-
done
580-
fi
526+
if [[ -f "./sing-box/sing-box.exe" && -f "./sing-box/config.json" ]]; then
527+
echo "检测到 sing-boxr 配置文件,是否更新?(Y/n)"
528+
while true; do
529+
read -n1 -r choice
530+
case $choice in
531+
[Yy])
532+
echo
533+
echo "正在下载 sing-boxr 配置文件..."
534+
curl -sS -o "$USERPROFILE/Downloads/config.json" -L https://ghfast.top/{.json 配置文件直链}
535+
echo "下载 sing-boxr 配置文件成功"
536+
537+
echo "正在结束 sing-boxr 相关进程..."
538+
taskkill //f //t //im "sing-box*"
539+
echo "结束 sing-boxr 相关进程成功"
540+
541+
echo "正在更新 sing-boxr 配置文件..."
542+
mv -f "$USERPROFILE/Downloads/config.json" ./sing-box
543+
echo "更新 sing-boxr 配置文件成功,是否启动服务?(Y/n)"
544+
ask_run
545+
break
546+
;;
547+
[Nn])
548+
break
549+
;;
550+
*)
551+
echo
552+
echo "无效选择,请重新输入!"
553+
;;
554+
esac
555+
done
556+
elif [ ! -f "./sing-box/config.json" ]; then
557+
echo "未检测到 sing-boxr 配置文件,是否导入?(Y/n)"
558+
while true; do
559+
read -n1 -r choice
560+
case $choice in
561+
[Yy])
562+
echo
563+
echo "正在导入 sing-boxr 配置文件..."
564+
curl -sS -o "$USERPROFILE/Downloads/config.json" -L https://ghfast.top/{.json 配置文件直链}
565+
mv -f "$USERPROFILE/Downloads/config.json" ./sing-box
566+
echo "导入 sing-boxr 配置文件成功,是否启动服务?(Y/n)"
567+
ask_run
568+
break
569+
;;
570+
[Nn])
571+
break
572+
;;
573+
*)
574+
echo
575+
echo "无效选择,请重新输入!"
576+
;;
577+
esac
578+
done
581579
else
582-
read -n1 -r -p "未检测到 sing-boxr 内核,请返回菜单安装内核!按任意键返回菜单..."
580+
read -n1 -r -p "未检测到 sing-boxr 内核,请先返回菜单安装内核!按任意键返回菜单..."
583581
fi
584582
;;
585583
3)
@@ -608,7 +606,7 @@ Windows Registry Editor Version 5.00
608606
;;
609607
esac
610608
done
611-
609+
612610
```
613611

614612
- ② 另存为 .sh 文件,右击并选择“以管理员身份运行”

_posts/2024-12-04-share-windows-mihomo-ruleset.md

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -529,47 +529,45 @@ Windows Registry Editor Version 5.00
529529
530530
echo "导入(更新)mihomo 配置文件"
531531
cd "$PROGRAMFILES"
532-
if [ -f "./mihomo/mihomo.exe" ]; then
533-
if [ -f "./mihomo/profiles/config.yaml" ]; then
534-
echo "检测到 mihomo 配置文件,是否更新?(Y/n)"
535-
while true; do
536-
read -n1 -r choice
537-
case $choice in
538-
[Yy])
539-
echo
540-
echo "正在下载 mihomo 配置文件..."
541-
curl -sS -o "$USERPROFILE/Downloads/config.yaml" -L https://ghfast.top/{.yaml 配置文件直链}
542-
echo "下载 mihomo 配置文件成功"
543-
544-
echo "正在结束 mihomo 相关进程..."
545-
taskkill //f //t //im "mihomo*"
546-
echo "结束 mihomo 相关进程成功"
547-
548-
echo "正在更新 mihomo 配置文件..."
549-
mv -f "$USERPROFILE/Downloads/config.yaml" ./mihomo/profiles
550-
echo "更新 mihomo 配置文件成功,是否启动服务?(Y/n)"
551-
ask_run
552-
break
553-
;;
554-
[Nn])
555-
break
556-
;;
557-
*)
558-
echo
559-
echo "无效选择,请重新输入!"
560-
;;
561-
esac
562-
done
563-
else
564-
echo "未检测到 mihomo 配置文件,导入配置文件..."
565-
mkdir -p ./mihomo/profiles
566-
curl -sS -o "$USERPROFILE/Downloads/config.yaml" -L https://ghfast.top/{.yaml 配置文件直链}
567-
mv -f "$USERPROFILE/Downloads/config.yaml" ./mihomo/profiles
568-
echo "导入 mihomo 配置文件成功,是否启动服务?(Y/n)"
569-
ask_run
570-
fi
532+
if [[ -f "./mihomo/mihomo.exe" && -f "./mihomo/profiles/config.yaml" ]]; then
533+
echo "检测到 mihomo 配置文件,是否更新?(Y/n)"
534+
while true; do
535+
read -n1 -r choice
536+
case $choice in
537+
[Yy])
538+
echo
539+
echo "正在下载 mihomo 配置文件..."
540+
curl -sS -o "$USERPROFILE/Downloads/config.yaml" -L https://ghfast.top/{.yaml 配置文件直链}
541+
echo "下载 mihomo 配置文件成功"
542+
543+
echo "正在结束 mihomo 相关进程..."
544+
taskkill //f //t //im "mihomo*"
545+
echo "结束 mihomo 相关进程成功"
546+
547+
echo "正在更新 mihomo 配置文件..."
548+
mv -f "$USERPROFILE/Downloads/config.yaml" ./mihomo/profiles
549+
echo "更新 mihomo 配置文件成功,是否启动服务?(Y/n)"
550+
ask_run
551+
break
552+
;;
553+
[Nn])
554+
break
555+
;;
556+
*)
557+
echo
558+
echo "无效选择,请重新输入!"
559+
;;
560+
esac
561+
done
562+
elif [ ! -f "./mihomo/profiles/config.yaml" ]; then
563+
echo "未检测到 mihomo 配置文件,导入配置文件..."
564+
mkdir -p ./mihomo/profiles
565+
curl -sS -o "$USERPROFILE/Downloads/config.yaml" -L https://ghfast.top/{.yaml 配置文件直链}
566+
mv -f "$USERPROFILE/Downloads/config.yaml" ./mihomo/profiles
567+
echo "导入 mihomo 配置文件成功,是否启动服务?(Y/n)"
568+
ask_run
571569
else
572-
read -n1 -r -p "未检测到 mihomo 内核,请返回菜单安装内核!按任意键返回菜单..."
570+
read -n1 -r -p "未检测到 mihomo 内核,请先返回菜单安装内核!按任意键返回菜单..."
573571
fi
574572
;;
575573
3)
@@ -598,7 +596,7 @@ Windows Registry Editor Version 5.00
598596
;;
599597
esac
600598
done
601-
599+
602600
```
603601

604602
- ② 另存为 .sh 文件,右击并选择“以管理员身份运行”

0 commit comments

Comments
 (0)