PrivateThoughts/run.sh

60 lines
1017 B
Bash
Raw Permalink Normal View History

DEV_USB=$1
MOUNT_NAME=priv
MOUNT_DIR=/media/michael/priv
error(){
echo "!\t$1"
2022-03-22 02:05:02 -04:00
exit 1
}
issue(){
echo "!\t$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 .`
2022-03-21 17:09:11 -04:00
echo "Unmounting db..."
umount -f "$MOUNT_DIR" ||\
issue "Issue unmounting $DEV_USB..."
rm -rf $MOUNT_DIR ||\
issue "Issue deleting mountpoint..."
echo "Removing link..."
rm -rf ./data.link
issue "Issue deleting link..."
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