76 lines
1.1 kB
1
rwx_file_append() {
2
local file="${1}"
3
local text="${2}"
4
if [ -n "${file}" ]; then
5
printf "%s" "${text}" >>"${file}"
6
fi
7
}
8
9
rwx_file_empty() {
10
local file="${1}"
11
if [ -n "${file}" ]; then
12
rwx_file_write "${file}" ""
13
fi
14
}
15
16
rwx_file_write() {
17
local file="${1}"
18
local text="${2}"
19
if [ -n "${file}" ]; then
20
printf "%s" "${text}" >"${file}"
21
fi
22
}
23
24
rwx_link() {
25
local link="${1}"
26
local target="${2}"
27
ln \
28
--symbolic \
29
"${target}" \
30
"${link}"
31
}
32
33
rwx_list_block_devices() {
34
lsblk \
35
--noempty \
36
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
37
}
38
39
rwx_not() {
40
case "${1}" in
41
"false") echo "true" ;;
42
"true") echo "false" ;;
43
*) ;;
44
esac
45
}
46
47
rwx_read_passphrase() {
48
rwx_read_secret "PassPhrase: "
49
}
50
51
rwx_read_secret() {
52
local prompt="${1}"
53
local secret
54
printf "%s" "${prompt}" 1>&2
55
stty -echo
56
read -r secret
57
stty echo
58
echo >&2
59
echo "${secret}"
60
unset secret
61
}
62
63
rwx_remove() {
64
rm \
65
--force \
66
--recursive \
67
"${@}"
68
}
69
70
rwx_warn_wipe() {
71
local tmp
72
rwx_list_block_devices
73
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
74
read -r tmp
75
rwx_log_trace "${tmp}"
76
}
77