From 2f8793b72811d13a6b46244e17ae452d061e8a05 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 5 Jul 2017 12:59:23 -0300 Subject: Move uniqueid read to a function system_get_uniqueid() --- src/etc/inc/system.inc | 18 ++++++++++++++++++ .../www/widgets/widgets/system_information.widget.php | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index c7c6be2..ed93d0f 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -2345,6 +2345,24 @@ function system_get_serial() { return get_single_sysctl('kern.hostuuid'); } +function system_get_uniqueid() { + global $g; + + $uniqueid_file="{$g['vardb_path']}/uniqueid"; + + if (empty($g['uniqueid'])) { + if (!file_exists($uniqueid_file)) { + mwexec("/usr/sbin/gnid > {$g['vardb_path']}/uniqueid " . + "2>/dev/null"); + } + if (file_exists($uniqueid_file)) { + $g['uniqueid'] = @file_get_contents($uniqueid_file); + } + } + + return ($g['uniqueid'] ?: ''); +} + /* * attempt to identify the specific platform (for embedded systems) * Returns an array with two elements: diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php index 838ee72..2109d3e 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -159,9 +159,9 @@ $rows_displayed = false; " . gettext("Netgate Device ID:") . " " . file_get_contents($idfile) . ""); + $uniqueid = system_get_uniqueid(); + if (!empty($uniqueid)) { + print("
" . gettext("Netgate Device ID:") . " {$uniqueid}"); } ?> -- cgit v1.1