From 12d520548534d34049021b2dec4d22f85cc2fb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S?= Date: Mon, 19 Mar 2018 14:51:18 +0100 Subject: [PATCH] Added the test to found duplicate --- evocheck.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index b34d42f..3f65521 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -727,14 +727,22 @@ if [ -e /etc/debian_version ]; then fi fi - if [ "IS_DUPLICATE_FS_LABEL" = 1 ]; then - # Only on systems that have lsblk + if [ "$IS_DUPLICATE_FS_LABEL" = 1 ]; then + # Only on systems which have lsblk if [ -x "$(which lsblk)" ]; then tmpFile=$(mktemp -p /tmp) for part in $(lsblk -n -o LABEL); do - echo $part >> $tmpFile + echo "$part" >> "$tmpFile" done - sort < $tmpFile | uniq -d + tmpOutput=$(sort < "$tmpFile" | uniq -d) + # If there is no duplicate, uniq will have no output + # So, if $tmpOutput is not null, there is a duplicate + if [ -n "$tmpOutput" ]; then + echo 'IS_DUPLICATE_FS_LABEL FAILED!' + # For debug, you may echo the contents of $tmpOutput + # echo $tmpOutput + fi + rm $tmpFile fi fi fi