Merge pull request #145 from wanhebin/dev

修复Broken pipe问题 #144
This commit is contained in:
wanhebin 2023-08-28 18:55:34 +08:00 committed by GitHub
commit 0c119aaba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,10 +22,9 @@ else
else else
echo "解码后的内容不符合clash标准尝试将其转换为标准格式" echo "解码后的内容不符合clash标准尝试将其转换为标准格式"
${Server_Dir}/tools/subconverter/subconverter -g &>> ${Server_Dir}/logs/subconverter.log ${Server_Dir}/tools/subconverter/subconverter -g &>> ${Server_Dir}/logs/subconverter.log
converted_content=$(cat ${Server_Dir}/temp/clash_config.yaml) converted_file=${Server_Dir}/temp/clash_config.yaml
# 判断转换后的内容是否符合clash配置文件标准 # 判断转换后的内容是否符合clash配置文件标准
#if cat ./temp/clash_config.yaml | jq 'has("proxies") and has("proxy-groups") and has("rules")' 2>/dev/null; then if awk '/^proxies:/{p=1} /^proxy-groups:/{g=1} /^rules:/{r=1} p&&g&&r{exit} END{if(p&&g&&r) exit 0; else exit 1}' $converted_file; then
if echo "$converted_content" | awk '/^proxies:/{p=1} /^proxy-groups:/{g=1} /^rules:/{r=1} p&&g&&r{exit} END{if(p&&g&&r) exit 0; else exit 1}'; then
echo "配置文件已成功转换成clash标准格式" echo "配置文件已成功转换成clash标准格式"
else else
echo "配置文件转换标准格式失败" echo "配置文件转换标准格式失败"