1
0
forked from apxtri/apxtri

test new repo

This commit is contained in:
philc 2024-03-23 09:24:01 +01:00
parent c6f6b3272a
commit 2e4686fa8d

View File

@ -10,25 +10,8 @@ const process = require("process");
/******************************************* /*******************************************
SEE https://gitea.ndda.fr/apxtri/apxtri/wiki/Devrules SEE README.md to have a quick understanding to install a new town
To have a quick understanding and convention before doing deeply in source code
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 * @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 * 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 ... * A folder for town data is created at the same level than apxtri as /townId-nationId/conf.json ...
*/ */
// check nginx exist const nam = path.resolve("../..").split("/").slice(-1)[0].split("-");
if (!fs.existsSync("/etc/nginx/nginx.conf")) { const town = nam[0];
console.log( 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." "\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(); 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 = {}; const param = {};
argv.slice(2).forEach((arg) => { argv.slice(2).forEach((arg) => {
const kv = arg.split(":"); const kv = arg.split(":");
@ -56,11 +55,7 @@ argv.slice(2).forEach((arg) => {
}); });
if (!fs.existsSync("../../conf.json")) { if (!fs.existsSync("../../conf.json")) {
// This is a first install // This is a first install
const nam = path.resolve("..").split("/").slice(-1)[0].split("-"); if (!setup(param)) process.exit();
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
} }
// setup_xx.json is gitignore so at first install we are in dev configuration // setup_xx.json is gitignore so at first install we are in dev configuration