source: alternc/branches/stable-1.0/src/quota_get.sh @ 2862

Revision 2862, 1.2 KB checked in by fufroma, 2 years ago (diff)

Ajout d'un "patch" pour quand on a pas activé les quota sur le disque.

  • Property svn:executable set to *
Line 
1#!/bin/bash
2. /etc/alternc/local.sh
3
4AWK=/usr/bin/awk
5DF=/bin/df
6SED=/bin/sed
7MOUNT=/bin/mount
8QUOTA=/usr/bin/quota
9GREP=/bin/grep
10WC=/usr/bin/wc
11
12DATA_PART=`$DF ${ALTERNC_LOC} 2>/dev/null | $AWK '/^\// { print $1 }'`
13
14# quota will give over NFS will print the partition using the full NFS name
15# (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount
16# to convert DATA_PART if needed.
17QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
18if [ -z "$QUOTA_PART" ]; then
19    QUOTA_PART="$DATA_PART"
20fi
21
22# quota will split its display on two lines if QUOTA_PART is bigger than 15
23# characters. *sigh*
24PART_LEN=`echo -n "$QUOTA_PART" | $WC -c`
25val=$(
26if [ "$PART_LEN" -gt 15 ]; then
27    $QUOTA -g "$1" |
28       $SED -n -e "\\;${QUOTA_PART};,+1s/ *\([0-9]*\) .*/\1/p" |
29       $GREP -v '^$'
30    $QUOTA -g "$1" |
31       $SED -n -e "\\;${QUOTA_PART};,+1s/ *[0-9]* *\([0-9]*\) .*/\1/p" |
32       $GREP -v '^$'
33else
34    $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$2'}
35    $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$3'}
36fi
37)
38
39# If the quota aren't activated, I return something anyway
40if [ -z "$val" ] ; then
41        echo 0
42        echo 0
43else   
44        echo -e "$val"
45fi
46
Note: See TracBrowser for help on using the repository browser.