osInfo() added FQDN

This commit is contained in:
Sebastian Hildebrandt
2020-12-06 15:50:04 +01:00
parent f6f5e83a2d
commit f94b6020eb
7 changed files with 48 additions and 3 deletions
+1
View File
@@ -285,6 +285,7 @@ export namespace Systeminformation {
kernel: string;
arch: string;
hostname: string;
fqdn: string;
codepage: string;
logofile: string;
serial: string;
+26
View File
@@ -17,6 +17,7 @@ const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
const fs = require('fs');
const { execSync } = require('child_process');
let _platform = process.platform;
@@ -160,6 +161,30 @@ function getLogoFile(distro) {
return result;
}
// --------------------------
// FQDN
function getFQDN() {
let fqdn = os.hostname;
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) {
try {
const stdout = execSync('hostname -f');
fqdn = stdout.toString().split(os.EOL)[0];
} catch (e) {
util.noop();
}
}
if (_windows) {
try {
const stdout = execSync('echo %COMPUTERNAME%.%USERDNSDOMAIN%');
fqdn = stdout.toString().split(os.EOL)[0];
} catch (e) {
util.noop();
}
}
return fqdn;
}
// --------------------------
// OS Information
@@ -176,6 +201,7 @@ function osInfo(callback) {
kernel: os.release(),
arch: os.arch(),
hostname: os.hostname(),
fqdn: getFQDN(),
codepage: '',
logofile: '',
serial: '',