From 2e4686fa8de14f5a1f7a1498eb30ab7e699b3198 Mon Sep 17 00:00:00 2001 From: philc Date: Sat, 23 Mar 2024 09:24:01 +0100 Subject: [PATCH] test new repo --- apxtri.js | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/apxtri.js b/apxtri.js index a6aaebe..25bd8af 100755 --- a/apxtri.js +++ b/apxtri.js @@ -10,25 +10,8 @@ const process = require("process"); /******************************************* -SEE https://gitea.ndda.fr/apxtri/apxtri/wiki/Devrules -To have a quick understanding and convention before doing deeply in source code +SEE README.md to have a quick understanding to install a new town -To share configuration : - process.env.dirtown is folder where town folder name /townId-nationId is accessible - const conf = require(`../../../conf.json`); - app.locals.tribeids is defined later in apixtrib.js and allow express app to always have in memory a dynamic of tribeId available in req.app.locals.tribeids -*/ -/** - * 1st install for dev - * run $ node apxtri.js nationId:ants townId:devfarm dns:devfarm-ants - * then just yarn dev - * it create a folder outside ../townId-nationId/ - * To convert a dev into a chain town run again with relevant param: - * run $ node apxtri.js nationId:ants townId:devfarm dns:devfarm-ants - * check the web interface http://dns - * then just yarn startpm2 your town is under PM2 control - * - * * @param {args} args key:value example node apxtri nationId:ants townId:devfarm dns:devfarm-ants * if no parameter from adminapi/www/adminapx/conf/setup_xx.json * @@ -40,13 +23,29 @@ To share configuration : * A folder for town data is created at the same level than apxtri as /townId-nationId/conf.json ... */ -// check nginx exist -if (!fs.existsSync("/etc/nginx/nginx.conf")) { - console.log( +const nam = path.resolve("../..").split("/").slice(-1)[0].split("-"); +const town = nam[0]; +const nation = nam[1]; +const setup=()=>{ + const nam = path.resolve("../..").split("/").slice(-1)[0].split("-"); + const town = nam[0]; + const nation = nam[1]; + let setupdone=true + // check nginx exist + if (!fs.existsSync("/etc/nginx/nginx.conf")) { + setupdone=false; + console.log( "\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available, install then rerun yarn command." ); process.exit(); } + if (! (param.dns && param.user) ) { + setupdone=false; + console.log("This is a first install you must run next command with a domain name (use town-nation for dev and the linux user that run apXtri) check ping dns answer and su user exist (check README) \n dns=domainname user=linuxuser yarn dev") + } + return setupdone; +} + const param = {}; argv.slice(2).forEach((arg) => { const kv = arg.split(":"); @@ -56,11 +55,7 @@ argv.slice(2).forEach((arg) => { }); if (!fs.existsSync("../../conf.json")) { // This is a first install - const nam = path.resolve("..").split("/").slice(-1)[0].split("-"); - const town = nam[0]; - const nation = nam[1]; - // doit exister param.dns pour mettre à jour le conf.json pour la conf adminapi - //run setup process + if (!setup(param)) process.exit(); } // setup_xx.json is gitignore so at first install we are in dev configuration