source: src/quota_get.sh @ 782

Revision 782, 2.0 KB checked in by anarcat, 7 years ago (diff)

[project @ fix conflicts in last patch]
this merges the ALTERNC_LOC patch with globenet's changes

it also removes alternc.conf from alternc, amongst other drastic changes.

Original author: Alternc dev team <dev@…>
Date: 2006-02-21 19:41:43

Line 
1#!/bin/sh
2. /etc/alternc/local.sh
3
4v v v v v v v
5DATA_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.
10QUOTA_PART=`mount | sed -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
11if [ -z "$QUOTA_PART" ]; then
12    QUOTA_PART="$DATA_PART"
13fi
14
15# quota will split its display on two lines if QUOTA_PART is bigger than 15
16# characters. *sigh*
17PART_LEN=`echo -n "$QUOTA_PART" | wc -c`
18if [ "$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"
23else
24    quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$2'}
25    quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$3'}
26fi
27
28*************
29v v v v v v v
30# quota doesn't doesn't give us the device, find it
31DATA_PART=`df ${ALTERNC_LOC} 2>/dev/null | awk '/^\// { print $1 }'`
32
33quota -g $1 | awk /${DATA_PART//\//\\\/}/\ {print\ '$2'}
34quota -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.
39QUOTA_PART=`mount | sed -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
40if [ -z "$QUOTA_PART" ]; then
41    QUOTA_PART="$DATA_PART"
42fi
43
44# quota will split its display on two lines if QUOTA_PART is bigger than 15
45# characters. *sigh*
46PART_LEN=`echo -n "$QUOTA_PART" | wc -c`
47if [ "$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"
52else
53    quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$2'}
54    quota -g "$1" | awk /${QUOTA_PART//\//\\\/}/\ {print\ '$3'}
55fi
56
57^ ^ ^ ^ ^ ^ ^
58^ ^ ^ ^ ^ ^ ^
Note: See TracBrowser for help on using the repository browser.