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..."