12 source /etc/alternc/local.sh
14 if [ "x$MID" == "x" ] ; then
15 echo "Usage: quota_get <uid>"
16 echo "Get the quota of the AlternC account having uid <uid>"
21 if [ "$NFS_QUOTA" = "yes" -o "$NFS_QUOTA" = "YES" -o "$NFS_QUOTA" = "Yes" ]
26 #checking if quotas are installed
27 command -v $QUOTA >/dev/null || { echo "Quotas uninstalled"; exit 0; }
30 # The second line is the one interesting
31 # We look precisely on the HTML directory. Why ? because it's surely
32 # the bigger one, and if someone separate it we need to look this one
33 # particulary. It should be interesting to cumulate quota of all mounted directory.
35 DATA_PART=`$DF "${ALTERNC_HTML}" 2>/dev/null | $AWK 'NR==2 { print $1 }'`
37 # quota will give over NFS will print the partition using the full NFS name
38 # (e.g. 10.0.0.1:/var/www/alternc) so we need to lookup first with mount
39 # to convert DATA_PART if needed.
41 QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
43 if [ -z "$QUOTA_PART" ]; then
44 QUOTA_PART="$DATA_PART"
45 #if the partition is an LVM one we need to adress the partition by its UUID
46 UUID=$( $BLKID | grep "$QUOTA_PART" | cut -f2 -s -d" " | sed 's/\(UUID="\)\(.*\)\(\"$\)/\2/')
49 quot=$(sudo quota $QUOTA_OPTIONS -wvg "$MID" | grep "$QUOTA_PART" | $AWK 'NR==1 {print $1;}' )
51 # Now we get the quota
52 #first by testing if the partition is referenced by UUID
53 val=$(sudo quota $QUOTA_OPTIONS -vwg "$MID" |grep "$UUID" | awk 'END { print $2 "\n" $3; }')
54 if [ -z "$val" ] ; then
55 val=$(sudo quota $QUOTA_OPTIONS -A -wg "$MID" |grep "$QUOTA_PART" | awk 'END { print $2 "\n" $3; }')
57 # If the quota aren't activated, I return something anyway
58 if [ -z "$val" ] ; then