2024-12-01 22:40:54 +00:00
|
|
|
rwx_file_append() {
|
|
|
|
local file="${1}"
|
|
|
|
local text="${2}"
|
|
|
|
if [ -n "${file}" ]; then
|
|
|
|
printf "%s" "${text}" >>"${file}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
rwx_file_empty() {
|
|
|
|
local file="${1}"
|
|
|
|
if [ -n "${file}" ]; then
|
|
|
|
rwx_file_write "${file}" ""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-12-01 15:39:55 +00:00
|
|
|
rwx_file_write() {
|
|
|
|
local file="${1}"
|
|
|
|
local text="${2}"
|
|
|
|
if [ -n "${file}" ]; then
|
2024-12-01 16:47:06 +00:00
|
|
|
printf "%s" "${text}" >"${file}"
|
2024-12-01 15:39:55 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-12-01 18:04:23 +00:00
|
|
|
rwx_link() {
|
|
|
|
local link="${1}"
|
|
|
|
local target="${2}"
|
|
|
|
ln \
|
2024-12-01 20:39:41 +00:00
|
|
|
--symbolic \
|
2024-12-01 18:04:23 +00:00
|
|
|
"${target}" \
|
|
|
|
"${link}"
|
|
|
|
}
|
|
|
|
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_list_block_devices() {
|
2024-11-16 12:25:02 +00:00
|
|
|
lsblk \
|
|
|
|
--noempty \
|
|
|
|
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
|
|
|
}
|
|
|
|
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_not() {
|
2024-11-12 05:42:16 +00:00
|
|
|
case "${1}" in
|
|
|
|
"false") echo "true" ;;
|
|
|
|
"true") echo "false" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
}
|
2024-11-12 08:28:08 +00:00
|
|
|
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_read_passphrase() {
|
|
|
|
rwx_read_secret "PassPhrase: "
|
2024-11-12 08:28:08 +00:00
|
|
|
}
|
|
|
|
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_read_secret() {
|
2024-11-12 08:28:08 +00:00
|
|
|
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
|
|
|
|
2024-12-01 18:01:05 +00:00
|
|
|
rwx_remove() {
|
|
|
|
rm \
|
|
|
|
--force \
|
|
|
|
--recursive \
|
|
|
|
"${@}"
|
|
|
|
}
|
|
|
|
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_warn_wipe() {
|
2024-11-16 12:22:55 +00:00
|
|
|
local tmp
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_list_block_devices
|
2024-11-16 12:22:55 +00:00
|
|
|
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
|
|
|
|
read -r tmp
|
2024-11-29 18:18:30 +00:00
|
|
|
rwx_log_trace "${tmp}"
|
2024-11-16 12:22:55 +00:00
|
|
|
}
|