osInfo() improved fqdn (linux)

This commit is contained in:
Sebastian Hildebrandt
2023-06-03 19:24:26 +02:00
parent bab409fbc1
commit 216eda32e1
4 changed files with 19 additions and 7 deletions
+12 -6
View File
@@ -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();