#!/bin/sh

xfsPath=$(dirname "$VOL_DIR")
pvcName=$(basename "$VOL_DIR")

# support xfs quota
type=`stat -f -c %T ${xfsPath}`
if [ ${type} == 'xfs' ]; then

    echo "support xfs quota"
    xfs_quota -x -c "limit -p bhard=0 ${pvcName}" ${xfsPath}
fi

rm -rf "$VOL_DIR"

if [ ${type} == 'xfs' ]; then
    echo "$(sed "/${pvcName}/d" /etc/projects)" >  /etc/projects
    echo "$(sed "/${pvcName}/d" /etc/projid)" >  /etc/projid
    xfs_quota -x -c "report -pbih" ${xfsPath}
fi
