Improving config handling & startup logic
This commit is contained in:
@@ -7,7 +7,7 @@ const modes = require("../config/modes");
|
||||
// Modules
|
||||
const { executeAsyncConsoleCommand } = require("../utilities/executeConsoleCommands.js");
|
||||
// Utilities
|
||||
const updateConfig = require("../utilities/updateConfig");
|
||||
const { updateId, updateConfigFile } = require("../utilities/updateConfig");
|
||||
const updatePreset = require("../utilities/updatePresets");
|
||||
const requests = require("../utilities/httpRequests");
|
||||
|
||||
@@ -67,17 +67,17 @@ async function checkLocalIP() {
|
||||
exports.checkConfig = async function checkConfig() {
|
||||
if (!config.clientConfig.ip) {
|
||||
const ipAddr = await checkLocalIP();
|
||||
updateConfig('ip', ipAddr);
|
||||
updateConfigFile('ip', ipAddr);
|
||||
}
|
||||
|
||||
if(!config.clientConfig.name) {
|
||||
const lastOctet = await checkLocalIP().spit('.')[-1];
|
||||
const clientName = `Radio-Node-${lastOctet}`;
|
||||
updateConfig('name', clientName);
|
||||
updateConfigFile('name', clientName);
|
||||
}
|
||||
|
||||
if(!config.clientConfig.port) {
|
||||
updateConfig('port', 3010);
|
||||
updateConfigFile('port', 3010);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,7 +97,7 @@ exports.checkIn = async () => {
|
||||
// Update the client's ID if the server accepted it
|
||||
if (responseObject.statusCode === 202) {
|
||||
config.clientConfig.id = responseObject.body.nodeId;
|
||||
updateConfig.updateId(responseObject.body.nodeId);
|
||||
updateId(responseObject.body.nodeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user