cdist-backup/cdist/conf/explorer/disks
Ander Punnar 1c152f0acb fix disks explorer (#753)
* fix disks explorer

* fix SC2230

* exclude floppies

* update comment about excluded floppies

* add link to linux documentation about device majors

* try to support netbsd

* update possible netbsd disk devices
2019-04-12 20:41:05 +02:00

30 lines
748 B
Bash
Executable file

#!/bin/sh -e
os="$( "$__explorer/os" )"
case "$os" in
freebsd)
sysctl -n kern.disks
;;
openbsd)
sysctl -n hw.disknames | grep -Eo '[sw]d[0-9]+' | xargs
;;
netbsd)
sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]' | xargs
;;
*)
# hopefully everything else is linux
if command -v lsblk > /dev/null
then
# exclude ram disks, floppies and cdroms
# https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
lsblk -e 1,2,11 -dno name | xargs
else
# fallback
find /dev \
-type b \
-regex '/dev/\(hd\|sd\|vd\)[a-z]+' \
-printf '%f '
fi
;;
esac