summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2019-07-25 13:25:55 +0200
committerRamón M. Gómez <ramongomez@us.es>2019-08-20 17:26:48 +0200
commit76c35c19836439ecec94ece0c7b27a877e8b07b9 (patch)
treeb19ebfb2a10a036d5988c552ae23634663da02fa /client
parent4a9fee1bb44a6f7f92425ac26cf02a0b65b6615f (diff)
#920: Truncate a long serial number.
Diffstat (limited to 'client')
-rwxr-xr-xclient/engine/Inventory.lib14
1 files changed, 9 insertions, 5 deletions
diff --git a/client/engine/Inventory.lib b/client/engine/Inventory.lib
index 1dd7173c..f3a779d7 100755
--- a/client/engine/Inventory.lib
+++ b/client/engine/Inventory.lib
@@ -90,7 +90,6 @@ esac
}
-
#/**
# ogGetSerialNumber
#@brief Obtiene el nº de serie del cliente.
@@ -98,17 +97,22 @@ esac
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2015-06-08
#*/ ##
-
function ogGetSerialNumber ()
{
+# Variables locales.
+local SERIALNO
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
- ogHelp "$FUNCNAME" "$FUNCNAME"
+ ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 123456"
return
fi
-# Obtener nº de serie (ignorar los no especificados)
-dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|to be filled|invalid entry)"
+# Obtener nº de serie (ignorar los no especificados).
+SERIALNO=$(dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|to be filled|invalid entry|default string)")
+# Truncar cadena si >25 caracteres.
+[ ${#SERIALNO} -gt 25 ] && SERIALNO="${SERIALNO:0:22}..."
+[ -n "$SERIALNO" ] && echo "$SERIALNO"
+return 0
}