| 1 | #!/bin/sh |
|---|
| 2 | . /etc/alternc/local.sh |
|---|
| 3 | |
|---|
| 4 | v v v v v v v |
|---|
| 5 | DATA_PART=`df ${ALTERNC_LOC} 2>/dev/null | awk '/^\// { print $1 }'` |
|---|
| 6 | |
|---|
| 7 | # quota will give over NFS will print the partition using the full NFS name |
|---|
| 8 | # (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount |
|---|
| 9 | # to convert DATA_PART if needed. |
|---|
| 10 | QUOTA_PART=`mount | sed -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"` |
|---|
| 11 | if [ -z "$QUOTA_PART" ]; then |
|---|
| 12 | QUOTA_PART="$DATA_PART" |
|---|
| 13 | fi |
|---|
| 14 | |
|---|
| 15 | # quota will split its display on two lines if QUOTA_PART is bigger than 15 |
|---|
| 16 | # characters. *sigh* |
|---|
| 17 | PART_LEN=`echo -n "$QUOTA_PART" | wc -c` |
|---|
| 18 | if [ "$PART_LEN" -gt 15 ]; then |
|---|
| 19 | quota -g "$1" | |
|---|
| 20 | sed -n -e "\\;${QUOTA_PART}w,+1s/ *\([0-9]*\).*/\1/p" |
|---|
| 21 | quota -g "$1" | |
|---|
| 22 | sed -n -e "\\;${QUOTA_PART}w,+1s/ *[0-9]* *\([0-9]*\).*/\1/p" |
|---|
| 23 | else |
|---|
| 24 | quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$2'} |
|---|
| 25 | quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$3'} |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | ************* |
|---|
| 29 | v v v v v v v |
|---|
| 30 | # quota doesn't doesn't give us the device, find it |
|---|
| 31 | DATA_PART=`df ${ALTERNC_LOC} 2>/dev/null | awk '/^\// { print $1 }'` |
|---|
| 32 | |
|---|
| 33 | quota -g $1 | awk /${DATA_PART//\//\\\/}/\ {print\ '$2'} |
|---|
| 34 | quota -g $1 | awk /${DATA_PART//\//\\\/}/\ {print\ '$3'} |
|---|
| 35 | ************* |
|---|
| 36 | # quota will give over NFS will print the partition using the full NFS name |
|---|
| 37 | # (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount |
|---|
| 38 | # to convert DATA_PART if needed. |
|---|
| 39 | QUOTA_PART=`mount | sed -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"` |
|---|
| 40 | if [ -z "$QUOTA_PART" ]; then |
|---|
| 41 | QUOTA_PART="$DATA_PART" |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 44 | # quota will split its display on two lines if QUOTA_PART is bigger than 15 |
|---|
| 45 | # characters. *sigh* |
|---|
| 46 | PART_LEN=`echo -n "$QUOTA_PART" | wc -c` |
|---|
| 47 | if [ "$PART_LEN" -gt 15 ]; then |
|---|
| 48 | quota -g "$1" | |
|---|
| 49 | sed -n -e "\\;${QUOTA_PART}w,+1s/ *\([0-9]*\).*/\1/p" |
|---|
| 50 | quota -g "$1" | |
|---|
| 51 | sed -n -e "\\;${QUOTA_PART}w,+1s/ *[0-9]* *\([0-9]*\).*/\1/p" |
|---|
| 52 | else |
|---|
| 53 | quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$2'} |
|---|
| 54 | quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$3'} |
|---|
| 55 | fi |
|---|
| 56 | |
|---|
| 57 | ^ ^ ^ ^ ^ ^ ^ |
|---|
| 58 | ^ ^ ^ ^ ^ ^ ^ |
|---|