From 868d1319720a4487cf08790a455d71653d78e0ee Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Sat, 18 Dec 2021 13:02:49 +0100 Subject: [PATCH] fix quota --- .gitignore | 1 + README.md | 12 ++++++++++-- action.sh | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1893f0a..f2920f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .htaccess .htpasswd config.cfg +quota diff --git a/README.md b/README.md index 9875984..59f49d4 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,17 @@ It's recommended to install UAAP automatically by using another script of mine, ### Manual method (not recommended, needs more work) -Download the git repository by using -`git clone http://src.mehl.mx/git/uberspace-setup.git` +Download the git repository by using +`git clone http://src.mehl.mx/git/uberspace-webadmin.git` I assume it's best to place these files in a subdomain. I used `panel.example.com` for that. Now open the files `config.cfg.sample`, `.htaccess.sample`, and `.htpasswd.sample` and change all necessary settings. Be sure to remove the `.sample` in the file names of these files afterwards. + +### Other steps + +On Uberspace 7, you'll need to create a cronjob to provide quota information because of SELinux limitations. To do so, edit your crontab with `crontab -e` and insert: + +``` +* * * * * quota -gsl > /var/www/virtual/MYUSERNAME/panel.example.com/quota +``` diff --git a/action.sh b/action.sh index 837c9f7..b28c82a 100755 --- a/action.sh +++ b/action.sh @@ -347,8 +347,8 @@ 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') + USAGE=$(cat quota | tail -n 1 | awk -F" " '{ print $2 }') + QUOTA=$(cat quota | tail -n 1 | awk -F" " '{ print $3 }' | sed 's/[A-Za-z]//g') # If smaller than 1M, set usage to 1M to avoid miscalcuations if ! echo $USAGE | grep -q "[A-Za-z]$"; then @@ -364,7 +364,7 @@ if [ "$ACTION" == "quota" ]; then PERC=$(echo "scale=2; 100 - $PERC" | bc) - echo "You have "$[$QUOTA - $USAGE]" MB free ($PERC %)." + echo "You have "$(($QUOTA - $USAGE))" MB free ($PERC %)." fi # /quota