From 9f78013d6b67785bb9845da7273e6c8e702bad25 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Mar 2022 01:09:56 -0400 Subject: [PATCH] Updated run.sh to take a device instead of a mount folder. Now it will take that device unlock it, mount it, start the docker container, and then auto close, unmount, and removing all residual data afterwards --- run.sh | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/run.sh b/run.sh index 1a11a3b..92437f9 100755 --- a/run.sh +++ b/run.sh @@ -1,16 +1,34 @@ -rm -rf ./data.link -ln -s "$1/notes" ./data.link -echo "Remade link" +DEV_USB=$1 +MOUNT_NAME=priv +MOUNT_DIR=/media/michael/priv -#echo "Start markdown viewer" -#echo "pandoc $1/notes/*.md | lynx -stdin" + +echo "Locking db..." +cryptsetup luksOpen $DEV_USB $MOUNT_NAME + +echo "Mounting db..." +mkdir $MOUNT_DIR +mount /dev/mapper/$MOUNT_NAME $MOUNT_DIR + + +echo "Remaking link..." +rm -rf ./data.link +ln -s "$MOUNT_DIR/notes" ./data.link + +echo "Waiting..." +sleep 10 echo "Starting container..." docker run --name privmd --rm -it -v `pwd`/data.link/:/notes `docker build -q .` echo "Unmounting db..." -luks=`lsblk | grep /media/michael/Return\ to\ mscalz | grep -o -e "luks-[[:alnum:]-]*"` -umount -f "$1" -cryptsetup luksClose /dev/mapper/$luks +umount -f "$MOUNT_DIR" +rm -rf $MOUNT_DIR + +echo "Removing link..." +rm -rf ./data.link + +echo "Locking db..." +cryptsetup luksClose /dev/mapper/$MOUNT_NAME echo "Exiting..."