cs/draft
This commit is contained in:
parent
fd4184c6a8
commit
f4136fd5a9
1 changed files with 49 additions and 3 deletions
|
@ -1,6 +1,52 @@
|
|||
_rwx_cmd_cs() { rwx_crypt_setup "${@}"; }
|
||||
_rwx_cmd_cs() { rwx_crypt "${@}"; }
|
||||
|
||||
rwx_crypt_setup() {
|
||||
RWX_CRYPT_ROOT="${HOME}/home/crypt"
|
||||
|
||||
rwx_crypt() {
|
||||
local action="${1}"
|
||||
echo "cs: ${action}"
|
||||
local action_close="close"
|
||||
local action_open="open"
|
||||
local mapper="/dev/mapper"
|
||||
local mount_root="/media"
|
||||
local crypt_arg crypt_file crypt_map crypt_mount pass_phrase
|
||||
case "${action}" in
|
||||
"${action_close}" | "${action_open}")
|
||||
shift
|
||||
if [ -z "${1}" ]; then
|
||||
rwx_log_error 1 "No files"
|
||||
fi
|
||||
[ "${action}" = "${action_open}" ] &&
|
||||
pass_phrase="$(rwx_read_passphrase)"
|
||||
for crypt_arg in "${@}"; do
|
||||
rwx_log_info
|
||||
crypt_file="${RWX_CRYPT_ROOT}/${crypt_arg}"
|
||||
if [ -f "${crypt_file}" ]; then
|
||||
crypt_map="${mapper}/${crypt_arg}"
|
||||
crypt_mount="${mount_root}/${crypt_arg}"
|
||||
case "${action}" in
|
||||
"${action_close}")
|
||||
rwx_log_info "CLOSE"
|
||||
# TODO unmount file system
|
||||
# TODO close device
|
||||
# TODO disconnect device
|
||||
;;
|
||||
"${action_open}")
|
||||
rwx_log_info "OPEN"
|
||||
# TODO find next available device
|
||||
# TODO connect device
|
||||
# TODO open device
|
||||
# TODO mount file system
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
else
|
||||
rwx_log_error 2 "Not a file"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
rwx_log_info "Usage:"
|
||||
rwx_log_info "${action_close}|${action_open}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue