diff --git a/setup.sh b/setup.sh index 8211378..37389ec 100644 --- a/setup.sh +++ b/setup.sh @@ -87,21 +87,14 @@ function we_have_exactly_one_part () { fi } -function no_zpool_exists () { - declare zpool_list - zpool_list="$(zpool list -H)" - [[ "$(wc -l <<<"${zpool_list}")" -le '1' ]] && [[ "$(wc -c <<<"${zpool_list}")" -le '1' ]] && return 0 - return 1 -} - -function zpool_drive_id () { +function get_drive_id () { declare drive_id drive_id="$(find -L /dev/disk/by-id -samefile "${1:?}")" - if [[ "$(wc -l <<<"${drive_id}")" -eq '1' ]]; then + if [[ "$(wc -l <<<"${drive_id}")" -eq '1' ]] && [[ "$(wc -c <<<"${drive_id}")" -gt '1' ]]; then printf -- '%s' "${drive_id}" return 0 fi - printf -- '%s\n' 'More than zpool partition entry in /dev/disk/by-id, exiting 1 ...' + printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...' exit 1 }