root/alternc/tags/0.9.7/src/quota_get.sh

Revision 1748, 1.0 kB (checked in by anarcat, 2 years ago)

faire que wc marche aussi avec le chemin absolu

  • Property svn:executable set to *
Line 
1 #!/bin/sh
2 . /etc/alternc/local.sh
3
4 AWK=/usr/bin/awk
5 DF=/bin/df
6 SED=/bin/sed
7 MOUNT=/bin/mount
8 QUOTA=/usr/bin/quota
9 GREP=/bin/grep
10 WC=/usr/bin/wc
11
12 DATA_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.
17 QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
18 if [ -z "$QUOTA_PART" ]; then
19     QUOTA_PART="$DATA_PART"
20 fi
21
22 # quota will split its display on two lines if QUOTA_PART is bigger than 15
23 # characters. *sigh*
24 PART_LEN=`echo -n "$QUOTA_PART" | $WC -c`
25 if [ "$PART_LEN" -gt 15 ]; then
26     $QUOTA -g "$1" |
27        $SED -n -e "\\;${QUOTA_PART};,+1s/ *\([0-9]*\) .*/\1/p" |
28        $GREP -v '^$'
29     $QUOTA -g "$1" |
30        $SED -n -e "\\;${QUOTA_PART};,+1s/ *[0-9]* *\([0-9]*\) .*/\1/p" |
31        $GREP -v '^$'
32 else
33     $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$2'}
34     $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$3'}
35 fi
36
Note: See TracBrowser for help on using the browser.