2024-04-06 03:03:58 +03:00
|
|
|
{ ... }: {
|
|
|
|
text = ''
|
|
|
|
# Show only physical drives info.
|
|
|
|
function pdf() {
|
|
|
|
df --si | sed -e '1p' -e '/^\/dev\//!d'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Show total size in SI.
|
|
|
|
# Current dir by default.
|
|
|
|
# Usage: tdu [DIRS]
|
|
|
|
function tdu() {
|
|
|
|
du -sh --si "''${@}"
|
|
|
|
}
|
2024-04-15 17:58:37 +03:00
|
|
|
|
|
|
|
# Unlock encrypted disk file.
|
2024-09-20 01:35:37 +03:00
|
|
|
# Usage: unlock <FILE> <DIR>
|
2024-04-15 17:58:37 +03:00
|
|
|
function unlock() {
|
2024-09-20 01:35:37 +03:00
|
|
|
if [[ "''${UID}" != 0 ]]; then
|
|
|
|
_error "Must be root."
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
2024-04-15 17:58:37 +03:00
|
|
|
local file="''${1}"
|
2024-09-20 01:35:37 +03:00
|
|
|
local dir="''${2}"
|
2024-04-15 17:58:37 +03:00
|
|
|
|
2024-09-20 01:35:37 +03:00
|
|
|
if [[ "''${dir}" = "" ]]; then
|
|
|
|
help unlock
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
local name=$(parse_alnum "''${file##*/}")
|
|
|
|
cryptsetup open "''${file}" "''${name}"
|
|
|
|
mount "/dev/mapper/''${name}" "''${dir}"
|
2024-04-15 17:58:37 +03:00
|
|
|
}
|
2024-09-20 01:35:37 +03:00
|
|
|
|
|
|
|
# Unlock encrypted disk file.
|
|
|
|
# Usage: unlock <FILE>
|
|
|
|
# function unlock() {
|
|
|
|
# _filter() {
|
|
|
|
# sed -e "s/.*\ a[st]\ //" -e "s/\.$//"
|
|
|
|
# }
|
|
|
|
# local file="''${1}"
|
|
|
|
# local name=$(parse_alnum ''${file} | _filter)
|
|
|
|
# local loop=$(udisksctl loop-setup -f "''${file}" | _filter)
|
|
|
|
# local unlock=$(udisksctl unlock -b "''${loop}" | _filter)
|
|
|
|
# local mount=$(udisksctl mount -b "''${unlock}" | _filter)
|
|
|
|
|
|
|
|
# [ -L "./''${name}" ] || ln -s "''${mount}" "./''${name}"
|
|
|
|
# cd "''${mount}"
|
|
|
|
# }
|
2024-04-06 03:03:58 +03:00
|
|
|
'';
|
|
|
|
}
|