#!/bin/bash
# Credit: https://www.exonet.nl/

# Wrapper around repquota to support /home on NFS

# Enable NFS on the NetApp volume and rename /usr/sbin/repquota to /usr/sbin/repquota.orig

if [ $@ == "/home" ]
then
       	echo "*** Report for user quotas on device /home
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------"
  for user in `ls -1 /home/`
   	do
   		if id "$user" >/dev/null 2>&1; then
        quotaoutput=`quota -u $user | tail -1`
  			quota=`echo $quotaoutput | awk {'print $1'}`
        softlimit=`echo $quotaoutput | awk {'print $2'}`
       	hardlimit=`echo $quotaoutput | awk {'print $3'}`
       	files=`echo $quotaoutput | awk {'print $4'}`
       	echo "$user -- $quota $softlimit $hardlimit $files 0 0"
      fi
       	done
else
 	repquota.orig $@
 	exit $?
fi

exit 1
