fix(脚本): 修改配置文件经过多用户配置操作后合并到一行导致可读性较差的问题

pull/534/merge
mack-a 2020-12-31 10:51:18 +08:00
parent 103a7316f6
commit 31ef9bb9b8
1 changed files with 22 additions and 11 deletions

View File

@ -2563,6 +2563,7 @@ addUser(){
if [[ -z ${userNum} || ${userNum} -le 0 ]] if [[ -z ${userNum} || ${userNum} -le 0 ]]
then then
echoContent red " ---> 输入有误,请重新输入" echoContent red " ---> 输入有误,请重新输入"
exit
fi fi
# 生成用户 # 生成用户
@ -2616,29 +2617,34 @@ addUser(){
if [[ ! -z `echo ${currentInstallProtocolType} | grep 0` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 0` ]]
then then
echo `cat ${configPath}02_VLESS_TCP_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'` > ${configPath}02_VLESS_TCP_inbounds.json local vlessTcpResult=`cat ${configPath}02_VLESS_TCP_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'`
echo ${vlessTcpResult} | jq . > ${configPath}02_VLESS_TCP_inbounds.json
fi fi
users=`echo ${users}|sed 's/"flow":"xtls-rprx-direct",//g'` users=`echo ${users}|sed 's/"flow":"xtls-rprx-direct",//g'`
if [[ ! -z `echo ${currentInstallProtocolType} | grep 1` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 1` ]]
then then
echo `cat ${configPath}03_VLESS_WS_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'` > ${configPath}03_VLESS_WS_inbounds.json local vlessWsResult=`cat ${configPath}03_VLESS_WS_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'`
echo ${vlessWsResult}|jq . > ${configPath}03_VLESS_WS_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType}|grep 2` ]] if [[ ! -z `echo ${currentInstallProtocolType}|grep 2` ]]
then then
echo `cat ${configPath}04_VMess_TCP_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'` > ${configPath}04_VMess_TCP_inbounds.json local vmessTcpResult=`cat ${configPath}04_VMess_TCP_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'`
echo ${vmessTcpResult}|jq . > ${configPath}04_VMess_TCP_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType} | grep 3` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 3` ]]
then then
echo `cat ${configPath}05_VMess_WS_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'` > ${configPath}05_VMess_WS_inbounds.json local vmessWsResult=`cat ${configPath}05_VMess_WS_inbounds.json|jq -r '.inbounds[0].settings.clients += ['${users}']'`
echo ${vmessWsResult}|jq . > ${configPath}05_VMess_WS_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType} | grep 4` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 4` ]]
then then
echo `cat ${configPath}../../trojan/config_full.json|jq -r '.password += ['${trojanGoUsers}']'` > ${configPath}../../trojan/config_full.json local trojanResult=`cat ${configPath}../../trojan/config_full.json|jq -r '.password += ['${trojanGoUsers}']'`
echo ${trojanResult}|jq . > ${configPath}../../trojan/config_full.json
handleTrojanGo stop handleTrojanGo stop
handleTrojanGo start handleTrojanGo start
fi fi
@ -2668,29 +2674,34 @@ removeUser(){
echoContent red " ---> 选择错误" echoContent red " ---> 选择错误"
else else
delUserIndex=`expr ${delUserIndex} - 1` delUserIndex=`expr ${delUserIndex} - 1`
echo `cat ${configPath}02_VLESS_TCP_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'` > ${configPath}02_VLESS_TCP_inbounds.json local vlessTcpResult=`cat ${configPath}02_VLESS_TCP_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'`
echo ${vlessTcpResult}|jq . > ${configPath}02_VLESS_TCP_inbounds.json
fi fi
fi fi
if [[ ! -z "${delUserIndex}" ]] if [[ ! -z "${delUserIndex}" ]]
then then
if [[ ! -z `echo ${currentInstallProtocolType} | grep 1` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 1` ]]
then then
echo `cat ${configPath}03_VLESS_WS_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'` > ${configPath}03_VLESS_WS_inbounds.json local vlessTcpResult=`cat ${configPath}03_VLESS_WS_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'`
echo ${vlessTcpResult}|jq . > ${configPath}03_VLESS_WS_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType}|grep 2` ]] if [[ ! -z `echo ${currentInstallProtocolType}|grep 2` ]]
then then
echo `cat ${configPath}04_VMess_TCP_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'` > ${configPath}04_VMess_TCP_inbounds.json local vlessTcpResult=`cat ${configPath}04_VMess_TCP_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'`
echo ${vlessTcpResult}|jq . > ${configPath}04_VMess_TCP_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType} | grep 3` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 3` ]]
then then
echo `cat ${configPath}05_VMess_WS_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'` > ${configPath}05_VMess_WS_inbounds.json local vlessTcpResult=`cat ${configPath}05_VMess_WS_inbounds.json|jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])'`
echo ${vlessTcpResult}|jq . > ${configPath}05_VMess_WS_inbounds.json
fi fi
if [[ ! -z `echo ${currentInstallProtocolType} | grep 4` ]] if [[ ! -z `echo ${currentInstallProtocolType} | grep 4` ]]
then then
echo `cat ${configPath}../../trojan/config_full.json|jq -r 'del(.password['${delUserIndex}'])'` > ${configPath}../../trojan/config_full.json local trojanResult=`cat ${configPath}../../trojan/config_full.json|jq -r 'del(.password['${delUserIndex}'])'`
echo ${trojanResult}|jq . > ${configPath}../../trojan/config_full.json
handleTrojanGo stop handleTrojanGo stop
handleTrojanGo start handleTrojanGo start
fi fi
@ -3222,7 +3233,7 @@ menu(){
cd cd
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v2.2.11" echoContent green "当前版本v2.2.12"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:七合一共存脚本" echoContent green "描述:七合一共存脚本"
echoContent red "==============================================================" echoContent red "=============================================================="