Fix disk detection units
authorRafael dos Santos Silva <xfalcox@gmail.com>
Tue, 12 May 2020 21:33:43 +0000 (18:33 -0300)
committerGitHub <noreply@github.com>
Tue, 12 May 2020 21:33:43 +0000 (18:33 -0300)
df was reporting bytes while du was reporting Kilobytes.

templates/postgres.template.yml

index 6731da066fb9aef517cd06177db5e17fd339ea5c..052825684a8ee212dc2534edbb2f00fb1fcca28e 100644 (file)
@@ -62,8 +62,8 @@ run:
 
        if [ ! "12" = "$PG_MAJOR_OLD" ]; then
          echo Upgrading PostgreSQL from version ${PG_MAJOR_OLD} to 12
-         free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
-         required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))
+         free_disk=$(df -P /shared | tail -n 1 | awk '{print $4}')
+         required=$(($(du -sb /shared/postgres_data | awk '{print $1}') * 2))
 
          if [ "$free_disk" -lt "$required" ]; then
           echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"