2022-03-22 01:09:56 -04:00
|
|
|
DEV_USB=$1
|
|
|
|
MOUNT_NAME=priv
|
|
|
|
MOUNT_DIR=/media/michael/priv
|
|
|
|
|
2022-03-27 18:40:24 -04:00
|
|
|
error(){
|
2022-03-27 20:10:03 -04:00
|
|
|
echo "!\t$1"
|
2022-03-22 02:05:02 -04:00
|
|
|
exit 1
|
2022-03-27 18:40:24 -04:00
|
|
|
}
|
|
|
|
|
2022-03-27 20:10:03 -04:00
|
|
|
issue(){
|
|
|
|
echo "!\t$1"
|
|
|
|
}
|
|
|
|
|
2022-03-27 18:40:24 -04:00
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
echo "Unlocking db..."
|
|
|
|
cryptsetup luksOpen $DEV_USB $MOUNT_NAME ||\
|
|
|
|
error "Issue unlocking db... quitting..."
|
2022-03-22 02:05:02 -04:00
|
|
|
|
2022-03-22 01:09:56 -04:00
|
|
|
|
|
|
|
echo "Mounting db..."
|
2022-03-22 02:05:02 -04:00
|
|
|
rm -rf $MOUNT_DIR
|
2022-03-27 18:40:24 -04:00
|
|
|
mkdir $MOUNT_DIR &&\
|
|
|
|
mount /dev/mapper/$MOUNT_NAME $MOUNT_DIR ||\
|
|
|
|
error "Issue mounting db... quitting..."
|
|
|
|
|
2022-03-22 01:09:56 -04:00
|
|
|
|
2022-03-27 18:40:24 -04:00
|
|
|
echo "Making link..."
|
2022-03-21 17:09:11 -04:00
|
|
|
rm -rf ./data.link
|
2022-03-27 18:40:24 -04:00
|
|
|
ln -s "$MOUNT_DIR/notes" ./data.link ||\
|
|
|
|
error "Issue mounting db... quitting..."
|
|
|
|
|
2022-03-21 17:09:11 -04:00
|
|
|
|
|
|
|
echo "Starting container..."
|
2022-03-27 20:10:03 -04:00
|
|
|
docker run --name priv --rm -it -v `pwd`/data.link/:/notes `docker build -q .`
|
2022-03-27 18:40:24 -04:00
|
|
|
|
2022-03-21 17:09:11 -04:00
|
|
|
|
|
|
|
echo "Unmounting db..."
|
2022-03-27 20:10:03 -04:00
|
|
|
umount -f "$MOUNT_DIR" ||\
|
|
|
|
issue "Issue unmounting $DEV_USB..."
|
2022-03-27 18:40:24 -04:00
|
|
|
rm -rf $MOUNT_DIR ||\
|
2022-03-27 20:10:03 -04:00
|
|
|
issue "Issue deleting mountpoint..."
|
2022-03-27 18:40:24 -04:00
|
|
|
|
2022-03-22 01:09:56 -04:00
|
|
|
|
|
|
|
echo "Removing link..."
|
|
|
|
rm -rf ./data.link
|
2022-03-27 20:10:03 -04:00
|
|
|
issue "Issue deleting link..."
|
2022-03-27 18:40:24 -04:00
|
|
|
|
2022-03-22 01:09:56 -04:00
|
|
|
|
|
|
|
echo "Locking db..."
|
2022-03-27 18:40:24 -04:00
|
|
|
cryptsetup luksClose /dev/mapper/$MOUNT_NAME ||\
|
|
|
|
error "Issue locking db... quitting..."
|
|
|
|
|
|
|
|
|
|
|
|
echo "Exiting gracefully..."
|
|
|
|
exit 0
|
|
|
|
|
2022-03-21 17:09:11 -04:00
|
|
|
|