2012-02-06 08:28:40 +00:00
|
|
|
#!/bin/bash
|
2013-05-13 11:58:06 +00:00
|
|
|
source /etc/alternc/local.sh
|
2013-12-12 17:21:24 +00:00
|
|
|
set -x
|
2012-02-06 08:28:40 +00:00
|
|
|
# Set disk quota to an user
|
|
|
|
# Won't work over NFS
|
2006-05-12 11:17:23 +00:00
|
|
|
|
2012-02-06 08:28:40 +00:00
|
|
|
MID=$1
|
|
|
|
SIZE=$2
|
2012-02-28 14:48:45 +00:00
|
|
|
AWK=/usr/bin/awk
|
2013-01-25 16:39:39 +00:00
|
|
|
MOUNT=/bin/mount
|
|
|
|
SED=/bin/sed
|
2012-02-28 14:48:45 +00:00
|
|
|
QUOTA=/usr/sbin/setquota
|
2013-01-25 16:39:39 +00:00
|
|
|
DF=/bin/df
|
2012-11-07 16:42:57 +00:00
|
|
|
|
|
|
|
#checking if quotas are installed
|
2013-02-07 17:39:05 +00:00
|
|
|
command -v $QUOTA >/dev/null || { echo "Quotas uninstalled"; exit 1; }
|
2012-11-07 16:42:57 +00:00
|
|
|
|
2012-02-06 08:28:40 +00:00
|
|
|
if [ $# -ne 2 ] || [[ ! "$MID" =~ ^[0-9]+$ ]] || [[ ! "$SIZE" =~ ^[0-9]+$ ]]; then
|
|
|
|
echo "Usage: quota_edit <uid> <size>"
|
|
|
|
echo "Edit the quota of the AlternC account having uid <uid> the the available space to <size>"
|
2013-01-25 16:39:39 +00:00
|
|
|
exit 1
|
2012-02-06 08:28:40 +00:00
|
|
|
fi
|
2006-05-12 11:17:23 +00:00
|
|
|
|
2013-12-12 17:21:24 +00:00
|
|
|
DATA_PART=`$DF -P "${ALTERNC_HTML}" 2>/dev/null | $AWK 'NR==2 { print $NF }'`
|
2013-01-25 16:39:39 +00:00
|
|
|
|
2013-12-12 17:21:24 +00:00
|
|
|
if [[ ! -e $DATA_PART"/aquota.group" ]]; then
|
|
|
|
echo "Group quota are not enabled on $DATA_PART filesystem "
|
|
|
|
exit 2
|
|
|
|
fi
|
2013-01-25 16:39:39 +00:00
|
|
|
|
|
|
|
|
2013-12-12 17:21:24 +00:00
|
|
|
sudo $QUOTA -r -g $MID $SIZE 0 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on $ALTERNC_HTML." >&2
|
2013-01-25 16:39:39 +00:00
|
|
|
|
|
|
|
|