Commit 34238183 authored by tywldx's avatar tywldx

fix

parent 7bc70551
...@@ -10,7 +10,6 @@ var options = { ...@@ -10,7 +10,6 @@ var options = {
var app = express(); var app = express();
var admin = express(); // the sub app var admin = express(); // the sub app
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json()) app.use(bodyParser.json())
...@@ -31,17 +30,45 @@ admin.get('/get_node_command/:name', function (req, res) { ...@@ -31,17 +30,45 @@ admin.get('/get_node_command/:name', function (req, res) {
admin.post('/add_new_proxy', function (req, res) { admin.post('/add_new_proxy', function (req, res) {
let request = req.body; let request = req.body;
var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)); console.log(request)
var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)).replace(/\n/,"");
var index = str.indexOf(request["namespace"]) var index = str.indexOf(request["namespace"])
let newstr = "",sourcestr;
if( index != -1 ){ if( index != -1 ){
//存在这个配置,判断是否是原有的IP
var reg = new RegExp(request["namespace"] + "\\|\\d*\\.\\d*\\.\\d*\\.\\d*");
try{
console.log(str)
console.log(reg)
sourcestr = str.match(reg);
console.log(sourcestr)
sourcestr = sourcestr[0]
}catch(e){
res.send({msg:"错误,请检查 docket_env_name.sh 文件"})
return
}
if(sourcestr != undefined){
var items = sourcestr.split("|");
if(items[1] == request["ip"]){
res.send({msg:"已经存在的配置"}); res.send({msg:"已经存在的配置"});
return return
}else{ }else{
let newstr = str + " " + request["namespace"] targetstr = request["namespace"] + "|" + request["ip"];
newstr = str.replace(sourcestr,targetstr);
}
}else{
res.send({msg:"错误1"})
return
}
}else{
newstr = str + " " + request["namespace"] + "|" + request["ip"];
//文件添加到这里面 //文件添加到这里面
execSync(`${newstr} > ../ngrok/docker_env_name.sh}`)
} }
newstr = newstr.replace(/\n/,"");
console.log(newstr)
console.log("------------------------")
execSync(`echo "${newstr}" > ../ngrok/docker_env_name.sh`)
execSync("../ngrok/make_frp_ini.sh"); execSync("../ngrok/make_frp_ini.sh");
res.send({msg:"执行完成"}); res.send({msg:"执行完成"});
}); });
......
...@@ -167,11 +167,12 @@ do ...@@ -167,11 +167,12 @@ do
for projectAndPort in ${projectAndPorts[@]} for projectAndPort in ${projectAndPorts[@]}
do do
var=(${projectAndPort//|/ }) var=(${projectAndPort//|/ })
namespace=(${host_name//|/ })
addFrpcSub ${var[0]}-${var[2]} http 127.0.0 1 8000 ${var[2]}-${host_name} $filename addFrpcSub ${var[0]}-${var[2]} http 127.0.0 1 8000 ${var[2]}-${host_name} $filename
createNginxHttpAndSSLConf ${var[2]}-qa${host_name} 192.168.6.6 ${var[1]} $nginxname/${var[0]}-${host_name}.conf createNginxHttpAndSSLConf ${var[2]}-qa${namespace[0]} ${namespace[1]} ${var[1]} $nginxname/${var[0]}-${namespace[0]}.conf
done done
done done
nginx -s reload # nginx -s reload
sh ${frp_file_path}/restart.sh # sh ${frp_file_path}/restart.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment