Disk : Reimplement the unlock function.
This commit is contained in:
parent
d60c721697
commit
90f4dbf89a
|
@ -13,19 +13,40 @@
|
|||
}
|
||||
|
||||
# Unlock encrypted disk file.
|
||||
# Usage: unlock <FILE>
|
||||
# Usage: unlock <FILE> <DIR>
|
||||
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)
|
||||
if [[ "''${UID}" != 0 ]]; then
|
||||
_error "Must be root."
|
||||
return 2
|
||||
fi
|
||||
|
||||
[ -L "./''${name}" ] || ln -s "''${mount}" "./''${name}"
|
||||
cd "''${mount}"
|
||||
local file="''${1}"
|
||||
local dir="''${2}"
|
||||
|
||||
if [[ "''${dir}" = "" ]]; then
|
||||
help unlock
|
||||
return 2
|
||||
fi
|
||||
|
||||
local name=$(parse_alnum "''${file##*/}")
|
||||
cryptsetup open "''${file}" "''${name}"
|
||||
mount "/dev/mapper/''${name}" "''${dir}"
|
||||
}
|
||||
|
||||
# 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}"
|
||||
# }
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue