add quota functionality

This commit is contained in:
2015-07-10 19:07:54 +03:00
parent 47a47d6331
commit 00db2a200a
2 changed files with 42 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ PASS=$(cat "$3")
## FUNCTIONS ## FUNCTIONS
function checkaction { 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 if [[ $1 =~ $REGEX ]]; then
echo "true" echo "true"
else else
@@ -332,6 +332,27 @@ if [ "$ACTION" == "userdetail" ]; then
fi # /userdetail 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 # DELETE USER
# # # # # # # # # #

View File

@@ -14,6 +14,10 @@
<h4>You have following options:</h4> <h4>You have following options:</h4>
<div id="gallery"> <div id="gallery">
<!--
GENERAL SECTION
-->
<p><strong>General</strong></p> <p><strong>General</strong></p>
<!-- VIEWDATA - View datasheet of whole account --> <!-- VIEWDATA - View datasheet of whole account -->
<b class="switch"><span class="turn_on">&#187;</span><span class="turn_off">&#171;</span> View the data sheet</b> <b class="switch"><span class="turn_on">&#187;</span><span class="turn_off">&#171;</span> View the data sheet</b>
@@ -26,6 +30,22 @@
</form> </form>
</div> <!-- /hide --> </div> <!-- /hide -->
<!-- QUOTA - Show free and used disk space an whole account -->
<b class="switch"><span class="turn_on">&#187;</span><span class="turn_off">&#171;</span> Show used disk space</b>
<div class="hide">
<p>Shows used and free disk space on your webhost. This sums up all
used space by emails, websites and databases.</p>
<form action="submit.php" method="post">
<button type="submit" name="action" value="quota">Show usage</button>
<!-- Hidden confirmation box -->
<input type="hidden" name="sure" value="yes" />
</form>
</div> <!-- /hide -->
<!--
EMAIL SECTION
-->
<p><strong>Email accounts</strong></p> <p><strong>Email accounts</strong></p>
<!-- ADDUSER - Add a new email account --> <!-- ADDUSER - Add a new email account -->
<b class="switch"><span class="turn_on">&#187;</span><span class="turn_off">&#171;</span> Add a new email</b> <b class="switch"><span class="turn_on">&#187;</span><span class="turn_off">&#171;</span> Add a new email</b>