Compare commits

...
Author SHA1 Message Date
Hornwitser bdfe8e630e v2.0.0-alpha.10.b hotfix for installer 2021-10-05 20:19:58 +02:00
Hornwitser 66719375af Fix installer not setting address and ctl config (#417)
Somehow the step of automatically obtaining the right address to apply
to slave.public_address, and asking for the master url and token for ctl
installations was implemented but the code to actually set it in the
relevant config was forgotten.
2021-10-05 20:05:44 +02:00
2 changed files with 16 additions and 2 deletions

No files matched your search

+15 -1
View File
@@ -119,6 +119,13 @@ async function execSlave(args) {
return await execFile(path.join("node_modules", ".bin", `clusterioslave${scriptExt}`), args); return await execFile(path.join("node_modules", ".bin", `clusterioslave${scriptExt}`), args);
} }
async function execCtl(args) {
if (dev) {
return await execFile("node", [path.join("packages", "ctl"), ...args]);
}
return await execFile(path.join("node_modules", ".bin", `clusterioctl${scriptExt}`), args);
}
function validateSlaveToken(token) { function validateSlaveToken(token) {
let parts = token.split("."); let parts = token.split(".");
if (parts.length !== 3) { if (parts.length !== 3) {
@@ -350,7 +357,7 @@ async function inquirerMissingArgs(args) {
} }
if (["standalone", "slave"].includes(answers.mode)) { if (["standalone", "slave"].includes(answers.mode)) {
let myIp; let myIp = "localhost";
if (args.publicAddress) { if (args.publicAddress) {
answers.publicAddress = args.publicAddress; answers.publicAddress = args.publicAddress;
} else { } else {
@@ -566,6 +573,7 @@ async function main() {
let slaveToken = result.stdout.split("\n").slice(-2)[0]; let slaveToken = result.stdout.split("\n").slice(-2)[0];
await execSlave(["config", "set", "slave.master_token", slaveToken]); await execSlave(["config", "set", "slave.master_token", slaveToken]);
await execSlave(["config", "set", "slave.public_address", answers.publicAddress]);
await execSlave(["config", "set", "slave.factorio_directory", answers.factorioDir]); await execSlave(["config", "set", "slave.factorio_directory", answers.factorioDir]);
} }
@@ -576,6 +584,7 @@ async function main() {
await execSlave(["config", "set", "slave.name", answers.slaveName]); await execSlave(["config", "set", "slave.name", answers.slaveName]);
await execSlave(["config", "set", "slave.master_url", answers.masterUrl]); await execSlave(["config", "set", "slave.master_url", answers.masterUrl]);
await execSlave(["config", "set", "slave.master_token", answers.masterToken]); await execSlave(["config", "set", "slave.master_token", answers.masterToken]);
await execSlave(["config", "set", "slave.public_address", answers.publicAddress]);
await execSlave(["config", "set", "slave.factorio_directory", answers.factorioDir]); await execSlave(["config", "set", "slave.factorio_directory", answers.factorioDir]);
} }
@@ -584,6 +593,11 @@ async function main() {
await writeScripts(answers.mode); await writeScripts(answers.mode);
} }
if (answers.mode === "ctl") {
await execCtl(["control-config", "set", "control.master_url", answers.masterUrl]);
await execCtl(["control-config", "set", "control.master_token", answers.masterToken]);
}
/* eslint-disable no-console */ /* eslint-disable no-console */
console.log(`Successfully installed ${answers.mode}`); console.log(`Successfully installed ${answers.mode}`);
if (adminToken) { if (adminToken) {
+1 -1
View File
@@ -3,7 +3,7 @@
"description": "Installer for clusterio", "description": "Installer for clusterio",
"author": "Hornwitser", "author": "Hornwitser",
"license": "MIT", "license": "MIT",
"version": "2.0.0-alpha.9", "version": "2.0.0-alpha.10.b",
"main": "create.js", "main": "create.js",
"bin": { "bin": {
"clusteriocreate": "./create.js" "clusteriocreate": "./create.js"