diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2020-07-04 23:12:49 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2020-07-04 23:12:49 +0200 |
commit | 8d273fe8d76ef394cfab04a195c90f4b7aeb8495 (patch) | |
tree | 56c3bfab8caf76643e43ec06057694f311db862e /nfs/scripts/funcs.sh | |
parent | 2f0e8730567070d66609633a4006b952eb13ab40 (diff) | |
download | eficast-8d273fe8d76ef394cfab04a195c90f4b7aeb8495.tar.gz eficast-8d273fe8d76ef394cfab04a195c90f4b7aeb8495.tar.bz2 eficast-8d273fe8d76ef394cfab04a195c90f4b7aeb8495.zip |
Fix firstdisk_test for NVMe, add $firstdisk and $firstdiskp vars
Diffstat (limited to 'nfs/scripts/funcs.sh')
-rw-r--r-- | nfs/scripts/funcs.sh | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nfs/scripts/funcs.sh b/nfs/scripts/funcs.sh index a1757a1..3d0d849 100644 --- a/nfs/scripts/funcs.sh +++ b/nfs/scripts/funcs.sh @@ -33,10 +33,23 @@ nfswrite_test() { fi } +firstdisk() { + # "sort", so we have nvme, then sata, then usb + lsblk -dnl --output TRAN,PATH | sort | head -n1 | awk '{print $2}' +} + +firstdiskp() { + # $1 : disk devnode path as return by firstdisk() + echo "$1" | grep -q '[0-9]$' && echo "${1}p" || echo "$1" +} + # no args, print colored message, returns 0 if sda is present and is sata, returns >0 if it is not firstdisk_test() { - diskinfo=$(lsblk --list --output TRAN,MODEL --noheadings --nodeps /dev/sda) + diskinfo=$(lsblk -dnl --output TRAN,MODEL "$1") case $diskinfo in + nvme*) echo_color green black ">>> First disk is NVMe and is available ($diskinfo)" + return 0 + ;; sata*) echo_color green black ">>> First disk is SATA and is available ($diskinfo)" return 0 ;; |