#!/bin/sh

LOOP_DEVICE=/dev/loop0
TMP_MOUNT=/mnt/tmp
STICK_MOUNT=/mnt/stick
LOOPBACK_FILE="loop-256.aes"

case "$1" in
	start)
		sudo /bin/mount -t vfat /dev/sda1 $TMP_MOUNT
		sudo /sbin/losetup -e aes -k 256 $LOOP_DEVICE $TMP_MOUNT/$LOOPBACK_FILE
		sudo /bin/mount $LOOP_DEVICE $STICK_MOUNT
		;;
	stop)
		sudo /bin/umount $STICK_MOUNT &> /dev/null
		sudo /sbin/losetup -d $LOOP_DEVICE &> /dev/null
		sudo /bin/umount $TMP_MOUNT &> /dev/null
		;;
  *)
		echo "pass start or stop as parameters"
		exit 1
		;;
esac

exit 0
	
