56 lines
1.0 KiB
Bash
Executable File
56 lines
1.0 KiB
Bash
Executable File
DEV_USB=$1
|
|
MOUNT_NAME=priv
|
|
MOUNT_DIR=/media/michael/priv
|
|
|
|
error(){
|
|
echo $1
|
|
exit 1
|
|
}
|
|
|
|
|
|
clear
|
|
|
|
echo "Unlocking db..."
|
|
cryptsetup luksOpen $DEV_USB $MOUNT_NAME ||\
|
|
error "Issue unlocking db... quitting..."
|
|
|
|
|
|
echo "Mounting db..."
|
|
rm -rf $MOUNT_DIR
|
|
mkdir $MOUNT_DIR &&\
|
|
mount /dev/mapper/$MOUNT_NAME $MOUNT_DIR ||\
|
|
error "Issue mounting db... quitting..."
|
|
|
|
|
|
echo "Making link..."
|
|
rm -rf ./data.link
|
|
ln -s "$MOUNT_DIR/notes" ./data.link ||\
|
|
error "Issue mounting db... quitting..."
|
|
|
|
|
|
echo "Starting container..."
|
|
docker run --name priv --rm -it -v `pwd`/data.link/:/notes `docker build -q .` ||\
|
|
error "Issue making docker container... quitting..."
|
|
|
|
|
|
echo "Unmounting db..."
|
|
umount -f "$MOUNT_DIR" &&\
|
|
rm -rf $MOUNT_DIR ||\
|
|
error "Issue unmounting and deleting mountpoint... quitting..."
|
|
|
|
|
|
echo "Removing link..."
|
|
rm -rf ./data.link
|
|
error "Issue deleting link... quitting..."
|
|
|
|
|
|
echo "Locking db..."
|
|
cryptsetup luksClose /dev/mapper/$MOUNT_NAME ||\
|
|
error "Issue locking db... quitting..."
|
|
|
|
|
|
echo "Exiting gracefully..."
|
|
exit 0
|
|
|
|
|