From 00db2a200ae4b56d70b81c72836bb64e79fd3b8d Mon Sep 17 00:00:00 2001 From: mxmehl Date: Fri, 10 Jul 2015 19:07:54 +0300 Subject: [PATCH] add quota functionality --- action.sh | 23 ++++++++++++++++++++++- index.php | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/action.sh b/action.sh index d878339..3f98c3f 100755 --- a/action.sh +++ b/action.sh @@ -36,7 +36,7 @@ PASS=$(cat "$3") ## FUNCTIONS function checkaction { - REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$|^sizeall$|^sizeuser$|^viewdata$|^addalias$" + REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$|^sizeall$|^sizeuser$|^viewdata$|^addalias$|^quota$" if [[ $1 =~ $REGEX ]]; then echo "true" else @@ -332,6 +332,27 @@ if [ "$ACTION" == "userdetail" ]; then fi # /userdetail +# # # # # +# QUOTA +# # # # # +if [ "$ACTION" == "quota" ]; then + echo "Calculating account disk usage..." + echo + + USAGE=$(quota -gsl | tail -n 1 | awk -F" " '{ print $2 }' | sed 's/[A-Za-z]//g') + QUOTA=$(quota -gsl | tail -n 1 | awk -F" " '{ print $3 }' | sed 's/[A-Za-z]//g') + + PERC=$(echo "scale=2; $USAGE/$QUOTA" | bc) + PERC=$(echo "scale=2; $PERC*100" | bc) + + echo "$USAGE MB of $QUOTA MB are used ($PERC %)." + + PERC=$(echo "scale=2; 100 - $PERC" | bc) + + echo "You have "$[$QUOTA - $USAGE]" MB free ($PERC %)." + +fi # /quota + # # # # # # DELETE USER # # # # # diff --git a/index.php b/index.php index fbdfe36..7571340 100644 --- a/index.php +++ b/index.php @@ -14,6 +14,10 @@

You have following options:

+ + »« Show used disk space +
+

Shows used and free disk space on your webhost. This sums up all + used space by emails, websites and databases.

+
+ + + +
+
+ + +

Email accounts

»« Add a new email