Compare commits

2 Commits

Author SHA1 Message Date
868d131972 fix quota 2021-12-18 13:03:21 +01:00
81fc921e3f fix quota calc 2021-12-18 12:01:20 +01:00
3 changed files with 102 additions and 93 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.htaccess
.htpasswd
config.cfg
quota

View File

@@ -26,8 +26,16 @@ 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`
`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
```

View File

@@ -347,11 +347,11 @@ if [ "$ACTION" == "quota" ]; then
echo "Calculating account disk usage..."
echo
USAGE=$(quota -gsl | tail -n 1 | awk -F" " '{ print $2 }')
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]$" ; echo $?) != 0 ]; then
if ! echo $USAGE | grep -q "[A-Za-z]$"; then
USAGE="1"
else
USAGE=$(echo $USAGE | sed 's/[A-Za-z]//g')
@@ -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