Resolved bug updating the config
This commit is contained in:
@@ -51,9 +51,10 @@ async function checkLocalIP() {
|
|||||||
line[1] = String(line[1]).replace(/(\\r|\\n)/g, "").trim();
|
line[1] = String(line[1]).replace(/(\\r|\\n)/g, "").trim();
|
||||||
return line;
|
return line;
|
||||||
});
|
});
|
||||||
log.DEBUG("Parsed IP Config Results: ", networkConfigLines);
|
networkConfig = Object.fromEntries(networkConfigLines);
|
||||||
log.DEBUG("Local IP address: ", networkConfigLines['IPv4Address']);
|
log.DEBUG("Parsed IP Config Results: ", networkConfig);
|
||||||
return networkConfigLines['IPv4Address'];
|
log.DEBUG("Local IP address: ", networkConfig['IPv4Address']);
|
||||||
|
return networkConfig['IPv4Address'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Linux
|
// Linux
|
||||||
@@ -67,17 +68,17 @@ async function checkLocalIP() {
|
|||||||
exports.checkConfig = async function checkConfig() {
|
exports.checkConfig = async function checkConfig() {
|
||||||
if (!config.clientConfig.ip) {
|
if (!config.clientConfig.ip) {
|
||||||
const ipAddr = await checkLocalIP();
|
const ipAddr = await checkLocalIP();
|
||||||
updateConfigFile('ip', ipAddr);
|
updateConfig('ip', ipAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!config.clientConfig.name) {
|
if(!config.clientConfig.name) {
|
||||||
const lastOctet = await checkLocalIP().spit('.')[-1];
|
const lastOctet = await String(checkLocalIP()).spit('.')[-1];
|
||||||
const clientName = `Radio-Node-${lastOctet}`;
|
const clientName = `Radio-Node-${lastOctet}`;
|
||||||
updateConfigFile('name', clientName);
|
updateConfig('name', clientName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!config.clientConfig.port) {
|
if(!config.clientConfig.port) {
|
||||||
updateConfigFile('port', 3010);
|
updateConfig('port', 3010);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ exports.updateId = (updatedId) => {
|
|||||||
exports.updateConfig = function updateConfig(key, value) {
|
exports.updateConfig = function updateConfig(key, value) {
|
||||||
const options = new Options(key, value);
|
const options = new Options(key, value);
|
||||||
|
|
||||||
this.updateConfigFile(options, (updatedFiles) => {
|
updateConfigFile(options, (updatedFiles) => {
|
||||||
// Do Something
|
// Do Something
|
||||||
log.DEBUG("Updated config file: ", updatedFiles);
|
log.DEBUG("Updated config file: ", updatedFiles);
|
||||||
})
|
})
|
||||||
@@ -43,7 +43,7 @@ exports.updateConfig = function updateConfig(key, value) {
|
|||||||
* @param options An instance of the Objects class specified to the key being updated
|
* @param options An instance of the Objects class specified to the key being updated
|
||||||
* @param callback Callback when the files have been modified
|
* @param callback Callback when the files have been modified
|
||||||
*/
|
*/
|
||||||
exports.updateConfigFile = function updateConfigFile(options, callback){
|
function updateConfigFile(options, callback){
|
||||||
replace(options, (error, changedFiles) => {
|
replace(options, (error, changedFiles) => {
|
||||||
if (error) return console.error('Error occurred:', error);
|
if (error) return console.error('Error occurred:', error);
|
||||||
log.DEBUG('Modified files:', changedFiles);
|
log.DEBUG('Modified files:', changedFiles);
|
||||||
|
|||||||
Reference in New Issue
Block a user