#!/bin/bash

# mount truecrypt volume on slot 5
# check filesystem if necessary

SLOT=5
MOUNTPOINT=/media/tr_md5/

date
echo mounting md5
truecrypt --version

if ! truecrypt -t -k "" --protect-hidden=no --slot=$SLOT /dev/md5 $MOUNTPOINT; then
	echo "mount failed"
	exit -3
fi

if ! ./mountcount.sh; then
	echo "mountcount reached"
	echo "pls provide root password"
	if !  su -c "umount $MOUNTPOINT && fsck -C -a -t ext3 /dev/mapper/truecrypt$SLOT"; then
		echo "dismount and fsck failed"
		exit -3
	fi
# fuck yeah, dismount everything!	
	truecrypt -d
	echo "please mount again"
fi

date



exit

