#!/bin/bash

if [ -L "$0" ]; then
	realpath=`readlink "$0"`
	sbinpath=`dirname $realpath`
else
	sbinpath=`dirname $0`
fi
sboxrel=`dirname $sbinpath`
SBOX_DIR=`readlink -f $sboxrel`

ERROR=0
if [ -d $SBOX_DIR/users ]; then
	for i in `ls -1 $SBOX_DIR/users/` ; do
		if ! $SBOX_DIR/sbin/sbox_umount $i ; then
			ERROR=1
		fi
	done
fi

if [ $ERROR = 1 ]; then
	echo
	echo "There were errors during the umounting!"
	echo
	exit 1
fi
