#!/bin/bash
# umountavfs -- program to unmount avfs file system
# and unload avfsd daemon.
# companion program to mountavfs
# will check to see if avfsd is mounted and then
# unmount using fusermount.
# last updated 2010-09-12

# suggested use: in a logout script or wm exit routine

if [ -d "$AVFSBASE" ]; then
    MntDir="$AVFSBASE"
else
    MntDir="${HOME}/.avfs"
fi

grep -qE "${MntDir}.*avfsd" /proc/mounts && {
   echo unMounting AVFS on $MntDir...
   if type -p fusermount > /dev/null 2>&1 ; then
      fusermount -u -z "$MntDir"
   else
      umount -l "$MntDir"
   fi
}
