PrivateThoughts/run.sh

56 lines
1.0 KiB
Bash
Raw Normal View History

DEV_USB=$1
MOUNT_NAME=priv
MOUNT_DIR=/media/michael/priv
error(){
echo $1
2022-03-22 02:05:02 -04:00
exit 1
}
clear
echo "Unlocking db..."
cryptsetup luksOpen $DEV_USB $MOUNT_NAME ||\
error "Issue unlocking db... quitting..."
2022-03-22 02:05:02 -04:00
echo "Mounting db..."
2022-03-22 02:05:02 -04:00
rm -rf $MOUNT_DIR
mkdir $MOUNT_DIR &&\
mount /dev/mapper/$MOUNT_NAME $MOUNT_DIR ||\
error "Issue mounting db... quitting..."
echo "Making link..."
2022-03-21 17:09:11 -04:00
rm -rf ./data.link
ln -s "$MOUNT_DIR/notes" ./data.link ||\
error "Issue mounting db... quitting..."
2022-03-21 17:09:11 -04:00
echo "Starting container..."
docker run --name priv --rm -it -v `pwd`/data.link/:/notes `docker build -q .` ||\
error "Issue making docker container... quitting..."
2022-03-21 17:09:11 -04:00
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
2022-03-21 17:09:11 -04:00