removing setup model replace into apxtrib.js argv

This commit is contained in:
philc 2023-06-01 07:30:05 +02:00
parent 908daaa8d3
commit c84a8c5aef
6 changed files with 32 additions and 551 deletions

View File

@ -6,7 +6,7 @@
# #
# ./sftpaccounttotribe.sh wall ants smatchit smatchapp sagark # ./sftpaccounttotribe.sh wall ants smatchit smatchapp sagark
@todo A faire # @todo A faire
echo $1; echo $1;
echo $2; echo $2;
echo $3; echo $3;
@ -19,7 +19,18 @@ create_sshspace () {
# Create a linux account with the name tribeId # Create a linux account with the name tribeId
# $ sudo useradd tribeId # $ sudo useradd tribeId
# $ passwd tribeId # $ passwd tribeId
# $ cd ~/workspace/towniD-natinId/tribes/tribeId/www # into /home/tribeswww/
# create /tribeId
# sudo mount --bind /home/phil/workspace/wall-ants/tribes/tribeId/www /home/tribeswww/tribeId
# add in /etc/fstab
# /home/phil/workspace/wall-ants/tribes/tribeId/www /home/tribeswww/tribeId none defaults,bind 0 0
#in /etc/ssh/sshd_config
#Match User smatchit
# ForceCommand internal-sftp
# ChrootDirectory /home/tribeswww/smatchit
# in /www/ need to add
# copy and past /bin dev/ /etc/ lib/ lib64/ # copy and past /bin dev/ /etc/ lib/ lib64/
# in /bin cp /bin/bash or /bin/sh depending of /etc/passwd SHELL (check /etc/default/useradd to change if needed) # in /bin cp /bin/bash or /bin/sh depending of /etc/passwd SHELL (check /etc/default/useradd to change if needed)
# to check dependance $ ldd /bin/bash # to check dependance $ ldd /bin/bash
@ -30,26 +41,11 @@ create_sshspace () {
# $ chmod -R 0755 /dev # $ chmod -R 0755 /dev
#$ sudo cp /etc/passwd ./etc/ Need to do each new user #$ sudo cp /etc/passwd ./etc/ Need to do each new user
#$ sudo cp /etc/group ./etc/ Need to do each new user #$ sudo cp /etc/group ./etc/ Need to do each new user
#
# To secure access nginx
# sudo apt install apache2-utils
#sudo mkdir -p /home/tribeswww/smatchit/smatchapp # sudo htpasswd -c /townId-natiuonId/tribes/tribeId/.htpasswd user
# cd /home/tribeswww/smatchit/smatchapp # user: smatchit psw: sm@tch1t
# sudo vim
# sudo mknod -m 666 null c 1 3;sudo mknod -m 666 tty c 5 0; sudo mknod -m 666 zero c 1 5; sudo mknod -m 666 random c 1 8;
# sudo chown root:root /home/tribeswww/smatchit/smatchapp
# sudo chmod 0755 /home/tribeswww/smatchit/smatchapp
# sudo mkdir -p /home/tribeswww/smatchit/smatchapp/bin
# sudo cp -v /bin/bash /home/tribeswww/smatchit/smatchapp/bin/
# sudo mkdir -p /home/tribeswww/smatchit/smatchapp/lib64
# check ldd /bin/bash
# sudo cp -v /lib64/{libtinfo.so.5,libdl.so.2,libc.so.6,ld-linux-x86-64.so.2} /home/tribeswww/smatchit/smatchapp/lib64/
# sudo useradd smatchapp;
# sudo passwd smatchapp;
# sudo mkdir /home/tribeswww/smatchit/smatchapp/etc
# sudo cp -vf /etc/{passwd,group} /home/tribeswww/smatchit/smatchapp/etc/ (this have to be done each time a new user is create)
#sudo vim /etc/ssh/sshd_config
} }

View File

@ -34,8 +34,13 @@ proxy_pass http://localhost:{{{api.port}}};
proxy_redirect off; proxy_redirect off;
include proxy_params; include proxy_params;
} }
#to add htpasswd install apache2-utils => sudo htpasswd -c dirtown/tribes/tribeId/.htpasswd loginname passwd see man for option
location / { location / {
{{#nginx.private}}
auth_basic "Mot de passe {{nginx.privatelogin}}";
auth_basic_user_file {{dirtown}}/tribes/{{tribeId}}/.htpasswd;
{{/nginx.private}}
root {{{nginx.fswww}}}/{{{nginx.website}}}; root {{{nginx.fswww}}}/{{{nginx.website}}};
index index.html {{{nginx.pageindex}}}; index index.html {{{nginx.pageindex}}};
} }

View File

@ -12,6 +12,7 @@
<li> install process made http://devfarm-ants available on your machine the /adminapi/www/adminapx/index_en.html to manage this dev town</li> <li> install process made http://devfarm-ants available on your machine the /adminapi/www/adminapx/index_en.html to manage this dev town</li>
<li>if not working, check that your /etc/hosts contain 127.0.0.1 devfarm-ants</li> <li>if not working, check that your /etc/hosts contain 127.0.0.1 devfarm-ants</li>
<li>start the api in apxtrib folder $ yarn dev to allow manager adminapx to act on this trib</li> <li>start the api in apxtrib folder $ yarn dev to allow manager adminapx to act on this trib</li>
<li>Restart nginx: sudo systemctl restart nginx</li>
</ul> </ul>
<p>Then you can dev in apxtrib to send your release to the project leader.</p> <p>Then you can dev in apxtrib to send your release to the project leader.</p>
<p>You can dev some app as a tribe level into /devfarm-ants see menu Mayor's Town/Manage Tribes to create a dev tribe. You can unzip a tribe into a folder for debuging or dev with real backup data.</p> <p>You can dev some app as a tribe level into /devfarm-ants see menu Mayor's Town/Manage Tribes to create a dev tribe. You can unzip a tribe into a folder for debuging or dev with real backup data.</p>
@ -38,7 +39,6 @@
<button class="btn btn-outline-secondary" type="button" id="button-chgown">Give him the role on this town</button> <button class="btn btn-outline-secondary" type="button" id="button-chgown">Give him the role on this town</button>
</div> </div>
{{/devtown}} {{/devtown}}
{{/owner}} {{/owner}}
</div> </div>

View File

@ -1,512 +0,0 @@
const { argv } = require("process");
const fs = require("fs-extra");
const path = require("path");
const dnsSync = require("dns-sync");
const mustache = require("mustache");
const readlineSync = require("readline-sync");
/**
* This Setup is run at the first installation
* This is not an exportable module
*
*
*
*/
const Setup = {};
//const nationsync = require('./Nations').updateChains();
Setup.check = (param) => {
//run a nationchains sync nd check town does not already exist
["nationId", "townId", "dns", "chain"].forEach((k) => {
if (!param[k]) {
console.log(`Please provide a ${k} in your param`);
process.exit();
}
});
const localconf = {
nationId: param.nationId,
townId: param.townId,
url:param.dns,
comment: "Generate by setup.js with minimum of information",
};
if (fs.existsSync(`../../adminapi/www/adminapx/conf/setup_xx.json`)) {
const setupxx=readJsonSYnc(`../../adminapi/www/adminapx/conf/setup_xx.json`)
if (setupxx.nationId==param.nationId && setupxx.townId=param.townId) {
// This is a re-install
}else{
console.log(
"A conf file exist in adminapi/www/adminapx/conf/setup_xx.json remove it an run again yarn setup ..."
);
process.exit();
}
}
fs.outputJsonSync(
`../../adminapi/www/adminapx/conf/setup_xx.json`,
localconf
);
const initconf = fs.readJsonSync(
"./adminapi/www/adminapx/tpldata/initconf.json"
);
let nationupdated = false;
const Wwws = require("../models/Wwws.js");
const Nations = require("../models/Nations.js");
for (let t = 0; t < initconf.towns; t++) {
const synchro = Nations.synchronize(initconf.towns[t].dns);
if (synchro.status == 200) {
nationupdated = true;
break;
}
}
if (!nationupdated) {
Console.log(
"Please check your internet access other towns cannot be reach to synchronize your town"
);
process.exit();
}
// check nationId exist and townId not
const idxnationId = fs.readJsonSync(
`../../nationchains/nations/idx/nationId_all.json`
);
if (!Object.keys(idxnationId).includes(param.nationId)) {
console.log(`Sorry your nationId: ${param.nationId} does not exist`);
process.exit();
}
const idxtownId = fs.readJsonSync(
"../../nationchains/towns/idx/townId_all.json"
);
if (Object.keys(idxtownId).includes(param.townId)) {
console.log(
`Sorry your townId: ${param.townId} already exist, please choose another one`
);
process.exit();
}
if ("testinternet" != "testinternet") {
console.log(
"\x1b[31m Check your internet access, to setup this town we need to update the Nations. It seems we cannot do it"
);
process.exit();
}
if (!fs.existsSync("/etc/nginx/nginx.conf")) {
console.log(
"\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available"
);
process.exit();
}
if (fs.existsSync("./adminapi/www/nginx_adminapx.conf")) {
console.log(
"\x1b[31m Be carefull you already have a town set, check http://adminapx or remove ./adminapi/www/nginx_adminapx.conf to reset nginxconf"
);
process.exit();
}
return true;
};
Setup.init = async (param) => {
/**
* create empty nationchains
* rsync all subfolder nationchains except the tribes/ and /www/nginx_adminapx.conf
*
* Then to send new version we fix a master production
*
*/
const initconf = fs.readJsonSync(
"./adminapi/www/adminapx/tpldata/initconf.json"
);
initconf.sudoerUser = process.env.USER;
initconf.dirapi = path.resolve(`${__dirname}/../../`);
initconf.dirtown = path.resolve(
`${__dirname}/../../../${param.townId}-${param.nationId}/`
);
// To allow to serve the nation website until the end
initconf.nginx.include.push(`${initconf.dirapi}/adminapi/www/nginx_*.conf`);
// To allow to serve tribes web site
initconf.nginx.include.push(`${initconf.dirtown}/tribes/*/www/nginx_*.conf`);
initconf.dns.push(param.dns);
initconf.nginx.logs = `${dirtown}/logs/nginx/adminapx`;
initconf.nginx.website = "adminapx";
initconf.nginx.fswww = `${dirapi}/adminapi/www`;
initconf.nginx.pageindex = "index_en.html";
const nginxconf = fs.readFileSync(
"../../adminapi/www/adminapx/static/tpl/nginx.conf.mustache",
"utf8"
);
const proxyparams = fs.readFileSync(
"../../adminapi/www/adminapx/static/tpl/nginxproxy_params.mustache",
"utf8"
);
// saved and change nginx conf
if (!fs.existsSync("/etc/nginx/nginxconf.saved")) {
fs.moveSync("/etc/nginx/nginx.conf", "/etc/nginx/nginxconf.saved");
console.log(
"your previous /etc/nginx/nginx.conf was backup in /etc/nginx/nginxconf.saved"
);
}
fs.outputFileSync(
"/etc/nginx/nginx.conf",
mustache.render(nginxconf, initconf),
"utf8"
);
fs.outputFileSync(
"/etc/nginx/proxy_params",
mustache.render(proxyparams, initconf),
"utf8"
);
if (!fs.existsSync(initconf.nginx.logs)) fs.mkdirSync(initconf.nginx.logs);
const { exec } = require("child_process");
exec(initconf.restart, (error, stdout, stderr) => {
if (error) {
console.log("\x1b[42m", error, stdout, stderr, "x1b[0m");
//@todo supprimer la derniere config et relancer
} else {
console.log(
`\x1b[42m###########################################################################################\x1b[0m\n\x1b[42mWellcome into apxtrib, you can now 'yarn dev' for dev or 'yarn startpm2' for prod or \n'yarn unittest' for testing purpose. Access to your town here \x1b[0m\x1b[32mhttp://${param.dns}\x1b[0m \x1b[42m \nto finish your town setup. Don't forget to set your localhost /etc/hosts by adding 127.0.0.1 adminapx or {LAN IP} adminapx . Check README's project to learn more. \x1b[0m\n\x1b[42m###########################################################################################\x1b[0m`
);
}
});
};
if (argv.length != 6) {
console.log(
"Check you parameter you need to type yarn setup nationId:ants townid:mytown dns:mytown-ants "
);
process.exit();
}
const param = {};
argv.slice(2).forEach((arg) => {
const kv = arg.split(":");
if (kv.length == 2) {
param[kv[0]] = kv[1];
} else {
console.log(
"Check your args that have to be yarn main key1:val1 keyn:valn"
);
process.exit(1);
}
});
console.log(param);
//if (Setup.check(param)) Setup.init(param);
// After testing remove all stuff after this line
Setup.initold = async () => {
// Get standard conf and current data
const townconf = fs.readJsonSync("./nationchains/www/adminapx/townconf.json");
const apxnations = fs.readJsonSync(
`./nationchains/nations/idx/nationId_all.json`
);
const apxtowns = fs.readJsonSync(`./nationchains/towns/idx/townId_all.json`);
let apxpagans = {};
if (fs.existsSync(`./nationchains/pagans/idx/alias_all.json`)) {
apxpagans = fs.readJsonSync(`./nationchains/pagans/idx/alias_all.json`);
}
if (!Object.keys(apxnations).includes(townconf.nationId)) {
console.log(
`Sorry nationId ${townconf.nationId} does not exist, please change with an existing nation `
);
process.exit();
}
if (Object.keys(apxtowns).includes(townconf.townId)) {
console.log(
`Sorry townId ${townconf.townId} already exist, please change it`
);
process.exit();
}
/*
if (Object.keys(apxpagans).includes(townconf.mayorId)) {
console.log(
`Sorry paganId ${townconf.maorId} already exist ti create a town you need a new identity, please change it`
);
process.exit();
}
*/
townconf.sudoerUser = process.env.USER;
townconf.dirapi = path.resolve(`${__dirname}/../../`);
// To allow to serve the nation website until the end
townconf.nginx.include.push(
`${townconf.dirapi}/nationchains/www/nginx_*.conf`
);
// To allow to serve tribes web site
townconf.nginx.include.push(
`${townconf.dirapi}/nationchains/tribes/*/www/nginx_*.conf`
);
townconf.nginx.logs = `${townconf.dirapi}/nationchains/logs/nginx`;
townconf.nginx.website = "adminapx";
townconf.nginx.fswww = "nationchains/"; //for a local tribe nationchains/tribes/tribeid
townconf.nginx.tribeid = "town";
townconf.nginx.pageindex = "index_en.html";
console.log(townconf);
if (
!readlineSync.keyInYN(
`\x1b[42mThis is the first install from ./nationchains/www/adminapx/townconf.json (check it if you want) \nthis will change your nginx config in /etc/nginx and run nginx from sudoer user ${townconf.sudoerUser} (Yes/no)? \nno if you want to change parameter and run yarn setup again \x1b[0m`
)
)
process.exit();
// saved and change nginx conf
if (!fs.existsSync("/etc/nginx/nginxconf.saved")) {
fs.moveSync("/etc/nginx/nginx.conf", "/etc/nginx/nginxconf.saved");
console.log(
"your previous /etc/nginx/nginx.conf was backup in /etc/nginx/nginxconf.saved"
);
}
const tplnginxconf = fs.readFileSync(
"./nationchains/www/adminapx/nginx/nginx.conf.mustache",
"utf8"
);
fs.outputFileSync(
"/etc/nginx/nginx.conf",
mustache.render(tplnginxconf, townconf),
"utf8"
);
//proxyparam
const proxy_params = fs.readFileSync(
"./nationchains/www/adminapx/nginx/proxy_params.mustache",
"utf8"
);
fs.outputFileSync(
"/etc/nginx/proxy_params",
mustache.render(proxy_params, townconf),
"utf8"
);
const tplnginxwww = fs.readFileSync(
"./nationchains/www/adminapx/nginx/modelwebsite.conf.mustache",
"utf8"
);
fs.outputFileSync(
`./${townconf.nginx.fswww}www/nginx_${townconf.nginx.website}.conf`,
mustache.render(tplnginxwww, townconf),
"utf8"
);
fs.outputJsonSync("./nationchains/tribes/conf.json", townconf, {
spaces: 2,
});
// Integrer cette partie du setup en inteactif.
// l'objectif du setup est de rendere accessible adminapx en local (IP local) ou production IP public
//CREATE A TOWN setup local voir utiliser towns.create
/* townconf.town = {
townId: townconf.townId,
nationId: townconf.nationId,
dns: `http://${townconf.dns[0]}`,
IP: townconf.IP,
mayorid: townconf.mayorId,
status: "unchain",
};
apxtowns[townconf.townId] = townconf.town;
fs.outputJsonSync(`./nationchains/towns/idx/townId_all.json`, apxtowns);
fs.outputJsonSync(
`./nationchains/towns/itm/${townconf.townId}.json`,
townconf.town,
{ spaces: 2 }
);
// Create tribe id voir a utiliser tribes.create()
townconf.tribe = {
tribeId: townconf.tribeId,
dns: [],
status: "unchain",
nationId: townconf.nationId,
townId: townconf.townId,
};
//tribe does not exist in a new town
apxtribes = {};
apxtribes[townconf.tribeId] = townconf.tribe;
fs.outputJsonSync(`./nationchains/tribes/idx/tribeId_all.json`, apxtribes);
fs.outputJsonSync(
`./nationchains/tribes/itm/${townconf.tribeId}.json`,
townconf.tribe,
{ spaces: 2 }
);
fs.ensureDirSync(`./nationchains/tribes/${townconf.tribeId}/logs/nginx`);
//CREATE a mayorId pagans if it does not exist
if (!apxpagans[townconf.mayorId]) {
const Pagans = require("./Pagans");
const createPagans = await Pagans.createId(
townconf.mayorId,
townconf.passphrase
);
if (createPagans.status == 200) {
fs.outputFileSync(
`./${townconf.mayorId}_PrivateKey.txt`,
createPagans.data.privateKey,
"utf8"
);
fs.outputFileSync(
`./${townconf.mayorId}_PublicKey.txt`,
createPagans.data.publicKey,
"utf8"
);
console.log(
`\x1b[43mCut paste your keys /${townconf.mayorId}_PrivateKey.txt /${townconf.mayorId}_PublicKey.txt \x1b[0m`
);
} else {
console.log("Error at Pagan creation ");
console.log(createPagans);
process.exit();
}
}*/
//fin de partie à integer dans l'interface graphique adminapx
//restart nginx
const { exec } = require("child_process");
exec(townconf.nginx.restart, (error, stdout, stderr) => {
if (error) {
console.log("\x1b[42m", error, stdout, stderr, "x1b[0m");
} else {
console.log(
`\x1b[42m###########################################################################################\x1b[0m\n\x1b[42mWellcome into apxtrib, you can now 'yarn dev' for dev or 'yarn startpm2' for prod or \n'yarn unittest' for testing purpose. Access to your town here \x1b[0m\x1b[32mhttp://${townconf.dns}\x1b[0m \x1b[42m \nto finish your town set up. Check README's project to learn more. \x1b[0m\n\x1b[42m###########################################################################################\x1b[0m`
);
}
});
};
Setup.Checkjson = (conf) => {
var rep = "";
const nation_town = fs.readJsonSync(
"./nationchains/socialworld/objects/towns/searchindex/towns_nation_uuid.json"
);
if (!ObjectKeys(nation_town).includes(conf.nationId)) {
rep += `your nationId ${conf.nationId} does not exist you have to choose an existing one`;
}
if (nation_town[conf.nationId].includes(conf.townId)) {
rep += `This conf.townId already exist you have to find a unique town name per nation`;
}
const getnation = Odmdb.get(
"./nationchains/socialworld/objects",
"towns",
[conf.NationId],
[nationId]
);
//if getnation.data.notfound
conf.language.forEach((l) => {
if (!["fr", "en", "it", "de", "sp"].includes(l)) {
rep += l + " Only fr,en,it,de,sp are available \n";
}
});
if (!fs.existsSync(`/home/${conf.sudoerUser}`)) {
rep += `/home/${conf.sudoerUser} does not exist, user has to be create with a /home on this server\n`;
}
try {
if (
"true" ==
execSync('timeout 2 sudo id && sudo="true" || sudo="false";echo "$sudo"')
.toString()
.trim()
.split(/\r?\n/)
.slice(-1)
) {
rep += `${sudoerUser} is not sudoer please change this `;
}
} catch (err) {
console.log(err);
rep += " Check your user it seems to not be a sudoer";
}
if (conf.jwtsecret.length < 32) {
rep += "Your jwtsecretkey must have at least 32 characters";
}
if (
conf.dns != "unchain" &&
!dnsSync.resolve(`${conf.townId}.${conf.nationId}.${conf.dns}`)
) {
rep += `\nresolving $${conf.townId}.${conf.nationId}.${conf.dns} will not responding valid IP, please setup domain redirection IP before runing this script`;
}
return rep;
};
Setup.config = (townSetup) => {
// Init this instance with a .config.js
Setup.configjs(townSetup);
// Create tribeid space + a user admin + webspace withe apxtrib webapp install
Setup.druidid(townSetup);
};
Setup.configjs = (townSetup) => {
// Set /config.js
let confapxtrib = fs.readFileSync("./setup/config.mustache", "utf-8");
fs.writeFileSync(
"./config.js",
Mustache.render(confapxtrib, townSetup),
"utf-8"
);
if (fs.existsSync("./config.js")) {
console.log("config.js successfully created.");
} else {
console.log(
"config.js not created, check what's wrong in tpl:",
confapxtrib
);
console.log("for data :", townSetup);
process.exit();
}
};
Setup.druidid = (townSetup) => {
// create a tribeid with a user that will admin this instance into /tribes/tribeid /users
const config = require("../config.js");
// Need to do it on setup this is also done again in models/Tribes.js
console.log(`${config.tribes}/${townSetup.druidid}`);
fs.ensureDirSync(`${config.tribes}/${townSetup.druidid}`);
["users", "www", "referentials", "nationchains"].forEach((r) => {
fs.copySync(
`${__dirapi}/setup/tribes/apxtrib/${r}`,
`${config.tribes}/${townSetup.druidid}/${r}`
);
});
/* const confcli = JSON.parse( Mustache.render( fs.readFileSync( `${__dirapi}/setup/tribes/apxtrib/clientconf.mustache`, 'utf8' ), townSetup ) );
fs.outputJsonSync( `${config.tribes}/${townSetup.druidid}/clientconf.json`, confcli );
// Create a new tribeid + admin user for this tribeid
// with access to {druidid}:webapp as admin
*/
const Tribes = require("./Tribes.js");
const access = { app: {}, data: {} };
access.app[`${townSetup.druidid}:webapp`] = "admin";
access.data[townSetup.druidid] = {
users: "CRUDO",
referentials: "CRUDO",
www: "CRUDO",
};
const createclient = Tribes.create({
tribeid: townSetup.druidid,
genericpsw: townSetup.genericpsw,
lanquageReferential: townSetup.language,
useradmin: {
LOGIN: townSetup.login,
xlang: townSetup.language[0],
ACCESSRIGHTS: access,
},
});
if (createclient.status == 200) {
console.log(
`Your tribeid domain was created with login : ${townSetup.login} and password: ${townSetup.genericpsw}, change it after the 1st login on https://${townSetup.subdomain}.${townSetup.domain}`
);
// Create nginx conf for a first install
const confnginx = fs.readFileSync(
"./setup/nginx/nginx.conf.mustache",
"utf8"
);
fs.outputFileSync(
"/etc/nginx/nginx.conf",
Mustache.render(confnginx, townSetup),
"utf-8"
);
// Create a spacedev for webapp of apxtrib
// that will be accesible in prod from https://subdomain.domain/ and in dev http://webapp.local.fr
const addspaceweb = Tribes.addspaceweb({
setup: true,
dnsname: [`${townSetup.subdomain}.${townSetup.domain}`],
mode: townSetup.mode,
tribeid: townSetup.druidid,
website: "webapp",
pageindex: "app_index_fr.html",
});
if (addspaceweb.status == 200) {
console.log(`WELL DONE run yarn dev to test then yarn startpm2 `);
}
} else {
console.log("Issue ", createclient);
}
};

View File

@ -3,24 +3,17 @@ const path = require("path");
const dnsSync = require("dns-sync"); const dnsSync = require("dns-sync");
const mustache = require("mustache"); const mustache = require("mustache");
const readlineSync = require("readline-sync"); const readlineSync = require("readline-sync");
const conf = require(`${process.env.dirtown}/conf.json`);
const conf = fs.existsSync("../../nationchains/tribes/conf.json")
? require("../../nationchains/tribes/conf.json")
: {};
const Wwws = {}; const Wwws = {};
Wwws.apxtribinstall = (paramconf) => { /*Wwws.apxtribinstall = (paramconf) => {
/** if (fs.existsSync(`${conf.dirtown}/conf.json`)) {
* First install for a setup
*
*/
if (fs.existsSync("../../nationchains/www/nginx_adminapx.conf")) {
console.log("You already have a conf on this town"); console.log("You already have a conf on this town");
process.exit(); process.exit();
} }
//first install //first install
const nginxconf = fs.readFileSync( const nginxconf = fs.readFileSync(
"../../nationchains/www/adminapx/static/tpl/nginx.conf.mustache", `${conf.dirapi}/adminapi/www/adminapx/conf/nginx.conf.mustache`,
"utf8" "utf8"
); );
const proxyparams = fs.readFileSync( const proxyparams = fs.readFileSync(
@ -52,11 +45,11 @@ Wwws.apxtribinstall = (paramconf) => {
return Www.create(paramconf.nginx); return Www.create(paramconf.nginx);
}; };
*/
Wwws.create = (paramnginx) => { Wwws.create = (paramnginx) => {
/** /**
* Create an nginx conf to make available https://adminapx on a local network * Create an nginx conf to make available a spaceweb for a tribe /www/appname/
* paramconf nginx.fswww place where the www folder is /tribeId/ *
*/ */
const res = { const res = {
status: 200, status: 200,
@ -65,7 +58,7 @@ Wwws.create = (paramnginx) => {
data: { website: paramnginx.website }, data: { website: paramnginx.website },
}; };
const nginxwebsite = fs.readFileSync( const nginxwebsite = fs.readFileSync(
"../../nationchains/www/adminapx/static/tpl/nginxmodelwebsite.conf.mustache", `${conf.dirapi}/adminapi/www/adminapx/conf/nginxmodelwebsite.conf.mustache`,
"utf8" "utf8"
); );
fs.outputFileSync( fs.outputFileSync(

View File

@ -17,7 +17,6 @@
"restartpm2": "pm2 restart apxtrib.js --log-date-format 'DD-MM HH:mm:ss.SSS'", "restartpm2": "pm2 restart apxtrib.js --log-date-format 'DD-MM HH:mm:ss.SSS'",
"startblockchain": "pm2 start api/models/Blockchains.js --log-date-format 'DD-MM HH:mm:ss:SSS'", "startblockchain": "pm2 start api/models/Blockchains.js --log-date-format 'DD-MM HH:mm:ss:SSS'",
"logpm2": "pm2 logs apxtrib.js --lines 200", "logpm2": "pm2 logs apxtrib.js --lines 200",
"setup": "node api/models/Setup.js",
"dev": "node apxtrib.js", "dev": "node apxtrib.js",
"unittest": "node unittest.js", "unittest": "node unittest.js",
"apidoc": "apidoc -e node_modules -i app -o nationchains/www/apidoc" "apidoc": "apidoc -e node_modules -i app -o nationchains/www/apidoc"