Created
August 11, 2018 14:39
-
-
Save kbhaines/83a658508e7155afa6e412190c9ddaf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -ne 3 ];then | |
echo "Usage: $0 <mount|unmount> <crypt-volume> <target-name>" | |
exit 0 | |
fi | |
ACTION=$1 | |
SRC=$2 | |
TARGET=$3 | |
TARGET_PATH=/media/$TARGET | |
case $ACTION in | |
mount) | |
mkdir $TARGET_PATH | |
LOOP=`losetup --show --find $SRC` | |
tcplay --map=$TARGET --device=$LOOP | |
mount /dev/mapper/$TARGET $TARGET_PATH | |
;; | |
unmount) | |
umount $TARGET_PATH | |
sleep 1 | |
dmsetup remove $TARGET | |
sleep 1 | |
LOOP=`losetup -n --output NAME -j $SRC` | |
losetup -d $LOOP | |
rmdir $TARGET_PATH | |
;; | |
*) exit 1 | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment