cleanup fix
This commit is contained in:
+5
-4
@@ -92,9 +92,9 @@ function run(command, consoleOutput = false) {
|
|||||||
async function main() {
|
async function main() {
|
||||||
await loadConfig();
|
await loadConfig();
|
||||||
|
|
||||||
instancesJSON = await readFile(config.instancesPath);
|
const instancesJSON = await readFile(config.instancesPath);
|
||||||
instancesPorts = "";
|
let instancesPorts = "";
|
||||||
upnpPortList = run('upnpc -l');
|
const upnpPortList = run('upnpc -l');
|
||||||
// console.log(upnpPortList);
|
// console.log(upnpPortList);
|
||||||
|
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ async function main() {
|
|||||||
for (const instancePort of JSON.parse(instance.DeploymentArgs['GenericModule.App.Ports'])) {
|
for (const instancePort of JSON.parse(instance.DeploymentArgs['GenericModule.App.Ports'])) {
|
||||||
let Name = `AMP ${instance.FriendlyName} ${instancePort.Name}`;
|
let Name = `AMP ${instance.FriendlyName} ${instancePort.Name}`;
|
||||||
let Number = instancePort.Port;
|
let Number = instancePort.Port;
|
||||||
instancesPorts = `${Name}\n`;
|
instancesPorts += `${Name}\n`;
|
||||||
|
|
||||||
if (!upnpPortList.includes(Name)) {
|
if (!upnpPortList.includes(Name)) {
|
||||||
switch (instancePort.Protocol) {
|
switch (instancePort.Protocol) {
|
||||||
@@ -160,6 +160,7 @@ async function main() {
|
|||||||
for (const portMap of upnpPortList.split('\n')) {
|
for (const portMap of upnpPortList.split('\n')) {
|
||||||
if (portMap.includes("AMP") && !instancesJSON.includes(portMap.split("'")[1])) {
|
if (portMap.includes("AMP") && !instancesJSON.includes(portMap.split("'")[1])) {
|
||||||
let found = portMap.match(/ *\d+ +(\w+) +(\d+).*/);
|
let found = portMap.match(/ *\d+ +(\w+) +(\d+).*/);
|
||||||
|
console.log(`Remove ${found[2]} ${found[1]}`);
|
||||||
run(`upnpc -d ${found[2]} ${found[1]}`);
|
run(`upnpc -d ${found[2]} ${found[1]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user