13 lines
549 B
Bash
13 lines
549 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
remote_host="${1:-tethys}"
|
||
|
|
max_bytes="${METIS_SD_MAX_BYTES:-300000000000}"
|
||
|
|
|
||
|
|
ssh "${remote_host}" "lsblk -S -b -dn -o NAME,TRAN,RM,HOTPLUG,SIZE,MODEL,SERIAL | while read -r name tran rm hotplug size model serial; do
|
||
|
|
if [ \"\${tran}\" = usb ] && [ \"\${hotplug}\" = 1 ] && [ \"\${size}\" -le ${max_bytes} ]; then
|
||
|
|
human=\$(numfmt --to=iec --suffix=B \"\${size}\" 2>/dev/null || printf '%sB' \"\${size}\")
|
||
|
|
printf '/dev/%s\t%s\t%s\t%s\n' \"\${name}\" \"\${human}\" \"\${model}\" \"\${serial}\"
|
||
|
|
fi
|
||
|
|
done"
|