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.
This commit is contained in:
Hornwitser authored and GitHub committed 2021-10-05 20:05:44 +02:00
1 parent ef3d5209eb
commit 66719375af
1 file changed
+15 -1
+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) {