feat(脚本): 1.添加多端口添加、管理 2.核心添加重启、打开、关闭功能

pull/534/merge
mack-a 2021-04-19 15:26:18 +08:00
parent d03ffe705b
commit 2223017e9d
1 changed files with 37 additions and 12 deletions

View File

@ -917,6 +917,9 @@ v2rayVersionManageMenu() {
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent yellow "1.升级" echoContent yellow "1.升级"
echoContent yellow "2.回退" echoContent yellow "2.回退"
echoContent yellow "3.关闭v2ray-core"
echoContent yellow "4.打开v2ray-core"
echoContent yellow "5.重启v2ray-core"
echoContent red "==============================================================" echoContent red "=============================================================="
read -r -p "请选择:" selectV2RayType read -r -p "请选择:" selectV2RayType
if [[ "${selectV2RayType}" == "1" ]]; then if [[ "${selectV2RayType}" == "1" ]]; then
@ -936,6 +939,12 @@ v2rayVersionManageMenu() {
echoContent red "\n ---> 输入有误,请重新输入" echoContent red "\n ---> 输入有误,请重新输入"
v2rayVersionManageMenu 1 v2rayVersionManageMenu 1
fi fi
elif [[ "${selectXrayType}" == "3" ]]; then
handleV2Ray stop
elif [[ "${selectXrayType}" == "4" ]]; then
handleV2Ray start
elif [[ "${selectXrayType}" == "5" ]]; then
reloadCore
fi fi
} }
@ -950,6 +959,9 @@ xrayVersionManageMenu() {
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent yellow "1.升级" echoContent yellow "1.升级"
echoContent yellow "2.回退" echoContent yellow "2.回退"
echoContent yellow "3.关闭Xray-core"
echoContent yellow "4.打开Xray-core"
echoContent yellow "5.重启Xray-core"
echoContent red "==============================================================" echoContent red "=============================================================="
read -r -p "请选择:" selectXrayType read -r -p "请选择:" selectXrayType
if [[ "${selectXrayType}" == "1" ]]; then if [[ "${selectXrayType}" == "1" ]]; then
@ -969,6 +981,12 @@ xrayVersionManageMenu() {
echoContent red "\n ---> 输入有误,请重新输入" echoContent red "\n ---> 输入有误,请重新输入"
xrayVersionManageMenu 1 xrayVersionManageMenu 1
fi fi
elif [[ "${selectXrayType}" == "3" ]]; then
handleXray stop
elif [[ "${selectXrayType}" == "4" ]]; then
handleXray start
elif [[ "${selectXrayType}" == "5" ]]; then
reloadCore
fi fi
} }
@ -2273,19 +2291,17 @@ addCorePort() {
echoContent skyBlue "\n功能 1/${totalProgress} : 添加新端口" echoContent skyBlue "\n功能 1/${totalProgress} : 添加新端口"
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent yellow "# 注意事项\n" echoContent yellow "# 注意事项\n"
echoContent yellow "1.只允许添加443之外的一个端口" echoContent yellow "不影响443端口的使用"
echoContent yellow "2.不影响443端口的使用" echoContent yellow "查看帐号时只会展示默认端口443的帐号\n"
echoContent yellow "3.查看帐号时只会展示默认端口443的帐号"
echoContent yellow "4.再次添加时会替换之前添加的端口"
echoContent red "=============================================================="
echoContent yellow "1.添加端口" echoContent yellow "1.添加端口"
echoContent yellow "2.卸载" echoContent yellow "2.删除端口"
echoContent red "==============================================================" echoContent red "=============================================================="
read -r -p "请选择:" selectNewPortType read -r -p "请选择:" selectNewPortType
if [[ "${selectNewPortType}" == "1" ]]; then if [[ "${selectNewPortType}" == "1" ]]; then
read -r -p "请输入端口号:" newPort read -r -p "请输入端口号:" newPort
if [[ -n "${newPort}" ]]; then if [[ -n "${newPort}" ]]; then
cat <<EOF >${configPath}02_dokodemodoor_inbounds.json cat <<EOF >${configPath}02_dokodemodoor_inbounds_${newPort}.json
{ {
"inbounds": [ "inbounds": [
{ {
@ -2305,7 +2321,7 @@ addCorePort() {
"tls" "tls"
] ]
}, },
"tag": "dokodemo-door-newPort" "tag": "dokodemo-door-newPort-${newPort}"
} }
] ]
} }
@ -2314,12 +2330,21 @@ EOF
reloadCore reloadCore
fi fi
elif [[ "${selectNewPortType}" == "2" ]]; then elif [[ "${selectNewPortType}" == "2" ]]; then
rm ${configPath}02_dokodemodoor_inbounds.json echoContent yellow "编号:端口"
echoContent green " ---> 卸载完成" ls ${configPath} | grep dokodemodoor | awk -F "[_]" '{print $4}' | awk -F "[.]" '{print ""NR""":"$1}'
reloadCore read -r -p "请输入要删除的端口编号:" portIndex
fi
local dokoConfig=$(ls ${configPath} | grep dokodemodoor | awk '{print ""NR""":"$1}' | grep ${portIndex}":")
if [[ -n "${dokoConfig}" ]]; then
rm ${configPath}/$(echo "${dokoConfig}" | awk -F "[:]" '{print $2}')
reloadCore
else
echoContent yellow "\n ---> 编号输入错误,请重新选择"
addCorePort
fi
fi
} }
# 卸载脚本 # 卸载脚本
unInstall() { unInstall() {
read -r -p "是否确认卸载安装内容?[y/n]:" unInstallStatus read -r -p "是否确认卸载安装内容?[y/n]:" unInstallStatus