From 146f329c249e064569391c2f90dc210cec91f634 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 20 Nov 2021 15:17:04 +0100 Subject: [PATCH 1/3] extend hostname enquiry For modern systemd-based systems (e.g. Arch), where command hostname might not exist anymore --- disk-burnin.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/disk-burnin.sh b/disk-burnin.sh index be099be..db4c195 100755 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -285,6 +285,8 @@ readonly LOG_DIR # System information readonly HOSTNAME="$(hostname)" +# Try command hostnamectl if HOSTNAME is unset or empty +[ -z HOSTNAME ] && readonly HOSTNAME="$(hostnamectl --static)" readonly OS_FLAVOR="$(uname)" # SMART static information From 75bda458098f862b9bc9b06ed71409f3ce510a59 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 22 Nov 2021 18:27:28 +0100 Subject: [PATCH 2/3] make HOSTNAE readonly only after value is set --- disk-burnin.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/disk-burnin.sh b/disk-burnin.sh index db4c195..a72334a 100755 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -284,9 +284,10 @@ LOG_DIR="$(printf '%s' "${LOG_DIR}" | awk '{gsub(/\/+$/, ""); printf $1}')" readonly LOG_DIR # System information -readonly HOSTNAME="$(hostname)" +HOSTNAME="$(hostname)" # Try command hostnamectl if HOSTNAME is unset or empty -[ -z HOSTNAME ] && readonly HOSTNAME="$(hostnamectl --static)" +[ -z HOSTNAME ] && HOSTNAME="$(hostnamectl --static)" +readonly HOSTNAME readonly OS_FLAVOR="$(uname)" # SMART static information From 85130b4f7228e809779f7cfbbf3a280210b0d6b1 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 22 Nov 2021 18:33:16 +0100 Subject: [PATCH 3/3] adapt to code style of the script --- disk-burnin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-burnin.sh b/disk-burnin.sh index a72334a..7b85cb4 100755 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -286,7 +286,7 @@ readonly LOG_DIR # System information HOSTNAME="$(hostname)" # Try command hostnamectl if HOSTNAME is unset or empty -[ -z HOSTNAME ] && HOSTNAME="$(hostnamectl --static)" +[ -z "${HOSTNAME}" ] && HOSTNAME="$(hostnamectl --static)" readonly HOSTNAME readonly OS_FLAVOR="$(uname)"