add listing of user/folder sizes

This commit is contained in:
2015-07-09 00:26:45 +03:00
parent 83fb97be4d
commit cc94102787
3 changed files with 47 additions and 4 deletions

View File

@@ -29,13 +29,13 @@
if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
source config.cfg
ACTION="$1" # adduser, changepw, listusers, userdetail, deluser
ACTION="$1" # adduser, changepw, listusers, userdetail, deluser, sizeall, sizeuser
USER="$2"
PASS="$3"
## FUNCTIONS
function checkaction {
REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$"
REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$|^sizeall$|^sizeuser$"
if [[ $1 =~ $REGEX ]]; then
echo "true"
else
@@ -157,7 +157,7 @@ if [ "$ACTION" == "changepw" ]; then
fi # /adduser
# # # # #
# DETAIL USER
# LIST USERS
# # # # #
if [ "$ACTION" == "listusers" ]; then
echo "Listing all Email accounts..."
@@ -167,6 +167,30 @@ if [ "$ACTION" == "listusers" ]; then
fi # /listusers
# # # # #
# SIZE ALL USERS
# # # # #
if [ "$ACTION" == "sizeall" ]; then
echo "Calculate total size of all Email accounts..."
echo
SYSUSER=$(whoami)
du -hs ~/users/* | sed -e 's:/home/$SYSUSER/users/::g'
fi # /sizeall
# # # # #
# SIZE USER
# # # # #
if [ "$ACTION" == "sizeuser" ]; then
echo "Calculate size of all folders of an Email account..."
echo
SYSUSER=$(whoami)
du -h ~/users/"$USER" | grep -v "new$\|cur$\|tmp$" | sed -e 's:/home/$SYSUSER/users/$USER/::g'
fi # /sizeuser
# # # # #
# USER DETAIL
# # # # #

View File

@@ -40,6 +40,25 @@
</form>
<hr />
<h3>Show total sizes of all Email accounts</h3>
<form action="submit.php" method="post">
<button type="submit" name="action" value="sizeall">Show size</button>
<!-- Hidden confirmation box -->
<input type="hidden" name="sure" value="yes" />
</form>
<hr />
<h3>Show size of every folder of a single Email account</h3>
<form action="submit.php" method="post">
<label>Username:</label>
<input name="user" title="User" />
<br />
<button type="submit" name="action" value="sizeuser">Show size</button>
<!-- Hidden confirmation box -->
<input type="hidden" name="sure" value="yes" />
</form>
<hr />
<h3>Detailed info about a single Email account</h3>
<form action="submit.php" method="post">
<label>Username:</label>

View File

@@ -37,7 +37,7 @@ else
</tr></td></table>
<p>In case of errors, please check all input data again.<br />
If problem still exists, please contact us and add the error message.</p>
If the problem still exists, please contact us and add the error message.</p>
</body>
</html>