mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-26 10:06:13 +01:00
11fc09120b
Signed-off-by: Magic_RB <magic_rb@redalder.org>
38 lines
579 B
Bash
38 lines
579 B
Bash
# -*- mode: shell-script; -*-
|
|
|
|
export PATH=@findutils@/bin:@busybox@/bin:@cryptsetup@/bin
|
|
|
|
command="$1"
|
|
|
|
if [ "$(id -u)" != "0" ]
|
|
then
|
|
echo "You must this script as root."
|
|
exit 1
|
|
fi
|
|
|
|
set -e
|
|
case "$command" in
|
|
"open")
|
|
cryptsetup open /dev/disk/by-label/secret secret
|
|
mkdir -p /mnt/key
|
|
|
|
mount /dev/mapper/secret /mnt/key
|
|
;;
|
|
"close")
|
|
umount /mnt/key
|
|
cryptsetup close secret
|
|
|
|
rm -r /mnt/key
|
|
if [ -n "$(find /mnt -maxdepth 0 -empty)" ]
|
|
then
|
|
rm -r /mnt
|
|
fi
|
|
;;
|
|
*)
|
|
cat <<EOF
|
|
open - open key
|
|
close - close key
|
|
EOF
|
|
;;
|
|
esac
|