From 216eda32e1b5644eeb95c2c2a2f95f117292d409 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 3 Jun 2023 19:24:26 +0200 Subject: [PATCH] osInfo() improved fqdn (linux) --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/osinfo.js | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd97a6..cc6f16e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.17.17 | 2023-06-03 | `osInfo()` improved fqdn (linux) | | 5.17.16 | 2023-05-30 | `usb()` fix parsing JSON (mac OS) | | 5.17.15 | 2023-05-29 | `powershell()` added NoProfile to speed up powershell (windows) | | 5.17.14 | 2023-05-29 | `diskLayout()`, `osInfo()` fix parsing issues (mac OS) | diff --git a/docs/history.html b/docs/history.html index 04fe5e5..251d145 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.17.17 + 2023-06-03 + osInfo() improved fqdn (linux) + 5.17.16 2023-05-30 diff --git a/docs/index.html b/docs/index.html index a18c35a..688b97b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.17.13
+
New Version: 5.17.17
diff --git a/lib/osinfo.js b/lib/osinfo.js index 154ca38..39573ed 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -168,15 +168,21 @@ function getFQDN() { let fqdn = os.hostname; if (_linux || _darwin) { try { - const stdout = execSync('hostname -f'); - fqdn = stdout.toString().split(os.EOL)[0]; + const stdout = execSync('hostnamectl --json short 2>/dev/null'); + const json = JSON.parse(stdout.toString()); + + fqdn = json['StaticHostname']; } catch (e) { - util.noop(); + try { + const stdout = execSync('hostname -f 2>/dev/null'); + fqdn = stdout.toString().split(os.EOL)[0]; + } catch (e) { + util.noop(); + } } - } - if (_freebsd || _openbsd || _netbsd) { + } if (_freebsd || _openbsd || _netbsd) { try { - const stdout = execSync('hostname'); + const stdout = execSync('hostname 2>/dev/null'); fqdn = stdout.toString().split(os.EOL)[0]; } catch (e) { util.noop();