From ba32b1a001b703fe99fcf74da80816ac31245a74 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Sun, 14 Jul 2019 12:18:05 +0200 Subject: [PATCH] Use xxd or hexdump, depending on OS --- include/helper_generate | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/helper_generate b/include/helper_generate index 31dba7ec..30044705 100644 --- a/include/helper_generate +++ b/include/helper_generate @@ -43,8 +43,18 @@ if [ $# -gt 0 ]; then fi # Generate random host IDs - HOSTID=$(head -c20 < /dev/urandom | xxd -c 20 -p) - HOSTID2=$(head -c32 < /dev/urandom | xxd -c 32 -p) + case "${OS}" in + "AIX") + # hexdump does not exist on AIX + HOSTID=$(head -c20 < /dev/urandom | xxd -c 20 -p) + HOSTID2=$(head -c32 < /dev/urandom | xxd -c 32 -p) + ;; + *) + # xxd does not exist on FreeBSD + HOSTID=$(head -c20 < /dev/urandom | hexdump -ve '"%.2x"') + HOSTID2=$(head -c32 < /dev/urandom | hexdump -ve '"%.2x"') + ;; + esac ${ECHOCMD} "Generated host identifiers" ${ECHOCMD} "- hostid: ${HOSTID}"