Alternc  latest
Alternc logiel libre pour l'hébergement
quota_edit
Go to the documentation of this file.
1 #!/bin/bash
2 source /etc/alternc/local.sh
3 set -x
4 # Set disk quota to an user
5 # Won't work over NFS
6 
7 MID=$1
8 SIZE=$2
9 AWK=/usr/bin/awk
10 MOUNT=/bin/mount
11 SED=/bin/sed
12 QUOTA=/usr/sbin/setquota
13 DF=/bin/df
14 
15 #checking if quotas are installed
16 command -v $QUOTA >/dev/null || { echo "Quotas uninstalled"; exit 1; }
17 
18 if [ $# -ne 2 ] || [[ ! "$MID" =~ ^[0-9]+$ ]] || [[ ! "$SIZE" =~ ^[0-9]+$ ]]; then
19  echo "Usage: quota_edit <uid> <size>"
20  echo "Edit the quota of the AlternC account having uid <uid> the the available space to <size>"
21  exit 1
22 fi
23 
24 DATA_PART=`$DF -P "${ALTERNC_HTML}" 2>/dev/null | $AWK 'NR==2 { print $NF }'`
25 
26 if [[ ! -e $DATA_PART"/aquota.group" ]]; then
27  echo "Group quota are not enabled on $DATA_PART filesystem "
28  exit 2
29 fi
30 
31 
32 sudo $QUOTA -r -g $MID $SIZE 0 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on $ALTERNC_HTML." >&2
33 
34