osInfo() added FQDN
This commit is contained in:
Vendored
+1
@@ -285,6 +285,7 @@ export namespace Systeminformation {
|
||||
kernel: string;
|
||||
arch: string;
|
||||
hostname: string;
|
||||
fqdn: string;
|
||||
codepage: string;
|
||||
logofile: string;
|
||||
serial: string;
|
||||
|
||||
@@ -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: '',
|
||||
|
||||
Reference in New Issue
Block a user