sh/sh/util.sh

38 lines
536 B
Bash
Raw Normal View History

2024-11-16 12:25:02 +00:00
list_block_devices() {
lsblk \
--noempty \
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
}
2024-11-12 05:42:16 +00:00
not() {
case "${1}" in
"false") echo "true" ;;
"true") echo "false" ;;
*) ;;
esac
}
2024-11-12 08:28:08 +00:00
read_passphrase() {
read_secret "PassPhrase: "
}
read_secret() {
local prompt="${1}"
local secret
2024-11-12 09:25:44 +00:00
printf "%s" "${prompt}" 1>&2
2024-11-13 12:08:09 +00:00
stty -echo
read -r secret
stty echo
2024-11-12 08:28:08 +00:00
echo >&2
echo "${secret}"
unset secret
}
2024-11-16 12:22:55 +00:00
warn_wipe() {
local tmp
2024-11-16 12:25:02 +00:00
list_block_devices
2024-11-16 12:22:55 +00:00
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
read -r tmp
2024-11-18 11:15:29 +00:00
sh_log_trace "${tmp}"
2024-11-16 12:22:55 +00:00
}