diff --git a/apxtri/apxtri.js b/apxtri/apxtri.js index 2a3454c..ed43b74 100755 --- a/apxtri/apxtri.js +++ b/apxtri/apxtri.js @@ -102,7 +102,7 @@ apxtri.setuptribe = async (tribe, conf) => { try { inittribe = conf; inittribe.townpath = __dirname.replace("/adminapi/apxtri", ""); - const townnation = inittribe.townpath.split("/").slice(-1)[0].split("-") + const townnation = inittribe.townpath.split("/").slice(-1)[0].split("-"); inittribe.townId = townnation[0]; inittribe.nationId = townnation[1]; inittribe.dns.push(`adminapi.${inittribe.townId}.${inittribe.nationId}`); @@ -114,7 +114,7 @@ apxtri.setuptribe = async (tribe, conf) => { console.log(`a new tribe called ${tribe} was detected`); inittribe = { tribeId: tribe, - townpath : __dirname.replace("/adminapi/apxtri", ""), + townpath: __dirname.replace("/adminapi/apxtri", ""), dns: [`admin.${tribe}.${conf.townId}.${conf.nationId}`], status: "unchain", nationId: conf.nationId, @@ -196,14 +196,18 @@ apxtri.setuptribe = async (tribe, conf) => { // this command is ran by the setup.sh // grep -q '^127.0.0.1 adminapx.adminapi' /etc/hosts || echo '127.0.0.1 adminapx.adminapi' | sudo tee -a /etc/hosts > /dev/null const ips = await getip(); + const nginrestart = initadminapi.nginx.restart + ? initadminapi.nginx.restart + : fs.readJSONSync("../adminapi/apxtri/setup/initadminapi.json").nginx + .restart; const { exec } = require("child_process"); - exec(initadminapi.nginx.restart, (error, stdout, stderr) => { + exec(nginxrestart, (error, stdout, stderr) => { if (error) { console.log("\x1b[42m", error, stdout, stderr, "x1b[0m"); process.exit(0); } else { const etchosts = Object.values(ips) - .map((ip) => `${ip} ${initadminapi.website}`) + .map((ip) => `${ip} ${inittribe.website}`) .join("\n "); console.log( `\x1b[42m###############################################################################################################\x1b[0m\n\x1b[42mWellcome into this fresh apxtri install, currently running as "$ yarn dev".\n To access and set up a public domain name, add lines in file /etc/hosts into the machine you want to use to access:\n ${etchosts} \n Then open in your local browser \x1b[0m\x1b[32m http://${initadminapi.website} \x1b[0m \x1b[42m \nFor local dev continue with 'yarn dev'\nTo run as a production run 'yarn startapx' or 'yarn restartapx' then pm2 monitor your production process.\n\x1b[0m\n\x1b[42m###############################################################################################################\x1b[0m`