refactor(history): commit development branch
All checks were successful
/ job (push) Successful in 1m12s
All checks were successful
/ job (push) Successful in 1m12s
new development branch from root commit
This commit is contained in:
parent
3e562930f6
commit
020aaa0b9a
94 changed files with 4804 additions and 0 deletions
76
sh/util.sh
Normal file
76
sh/util.sh
Normal file
|
@ -0,0 +1,76 @@
|
|||
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
|
||||
}
|
||||
|
||||
rwx_file_write() {
|
||||
local file="${1}"
|
||||
local text="${2}"
|
||||
if [ -n "${file}" ]; then
|
||||
printf "%s" "${text}" >"${file}"
|
||||
fi
|
||||
}
|
||||
|
||||
rwx_link() {
|
||||
local link="${1}"
|
||||
local target="${2}"
|
||||
ln \
|
||||
--symbolic \
|
||||
"${target}" \
|
||||
"${link}"
|
||||
}
|
||||
|
||||
rwx_list_block_devices() {
|
||||
lsblk \
|
||||
--noempty \
|
||||
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
||||
}
|
||||
|
||||
rwx_not() {
|
||||
case "${1}" in
|
||||
"false") echo "true" ;;
|
||||
"true") echo "false" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
rwx_read_passphrase() {
|
||||
rwx_read_secret "PassPhrase: "
|
||||
}
|
||||
|
||||
rwx_read_secret() {
|
||||
local prompt="${1}"
|
||||
local secret
|
||||
printf "%s" "${prompt}" 1>&2
|
||||
stty -echo
|
||||
read -r secret
|
||||
stty echo
|
||||
echo >&2
|
||||
echo "${secret}"
|
||||
unset secret
|
||||
}
|
||||
|
||||
rwx_remove() {
|
||||
rm \
|
||||
--force \
|
||||
--recursive \
|
||||
"${@}"
|
||||
}
|
||||
|
||||
rwx_warn_wipe() {
|
||||
local tmp
|
||||
rwx_list_block_devices
|
||||
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
|
||||
read -r tmp
|
||||
rwx_log_trace "${tmp}"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue