Merge branch '19-detect-depulicate-filesystem-labels' into 'master'

Resolve "Detect depulicate filesystem labels"

Closes #19

See merge request evolix/evocheck!9
This commit is contained in:
Benoît S. 2018-03-19 14:55:21 +01:00
commit f5f788874d

View file

@ -99,6 +99,7 @@ IS_MONGO_BACKUP=1
IS_MOUNT_FSTAB=1
IS_NETWORK_INTERFACES=1
IS_EVOBACKUP=1
IS_DUPLICATE_FS_LABEL=1
IS_EVOMAINTENANCE_FW=1
#Proper to OpenBSD
@ -734,6 +735,25 @@ if [ -e /etc/debian_version ]; then
&& test -f /etc/squid/evolinux-custom.conf) || echo 'IS_SQUIDEVOLINUXCONF FAILED!'
fi
fi
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"
done
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