#!/bin/sh

MOUNT_DIRECTORY=$1

# In case it doesn't exist
cd $MOUNT_DIRECTORY || exit 1
# Check if mountpoint to be deleted actually exists... :D
if [ ! -d "$2" ]; then exit 1; fi
# Delete the mount point indicated by the first argument, but not before
# checking mounted file systems for the same
if ! mount | grep -q "${MOUNT_DIRECTORY}/${2}"; then
  rm -r ${2}
fi
