view umount-crypt @ 1:182cce081e61

Make Mercirual only track explicitly added files (because /usr/local/bin also has game scripts, which don't need versioning)
author IBBoard <dev@ibboard.co.uk>
date Sat, 02 Aug 2014 20:02:06 +0100
parents e85e3470a41e
children 14e726efe9b0
line wrap: on
line source

#! /bin/bash

if [ $# -ne 1 ]; then
	echo "Usage: $0 <filename>" >&2
	exit 1
fi

if [ ! -d "$1" ]; then
	echo "Directory doesn't exist" >&2
	exit 2
fi

ARG=${1%/}
LOOP_DEV=${ARG##*/}

if [ ! -d "/media/$LOOP_DEV" -o ! -b "/dev/mapper/$LOOP_DEV" ]; then
	echo "Not a crypto loop" >&2
	exit 3
fi

sudo umount "/media/$LOOP_DEV"
sudo rmdir "/media/$LOOP_DEV"
sudo cryptsetup luksClose "/dev/mapper/$LOOP_DEV"
sudo losetup -d "/dev/$LOOP_DEV"