#!/bin/bash

ME="$0"
if [ -h "$0" ] ; then
	ME=`readlink -f "$0"`
fi

sbinpath=`dirname "$ME"`
if [ "z$sbinpath" = 'z.' ] ; then
	sbinpath=`pwd`
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
