#!/bin/bash

mp=$1

if [ ${mp::6} = "/sftp/"  ]; then
    # Check if directory exists
    if [ -d "${mp}" ]; then
        # Check if directory is mounted
        if mountpoint -q "${mp}"; then
            # Unmount directory
            if ! umount "${mp}"; then
                exit 1
            fi
        fi
        # Remove directory
        rm -rf "${mp}"
    fi
fi
