]> git.ipfire.org Git - people/jschlag/ipfire-3.x-image.git/commitdiff
Rework free space check
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 22 Jun 2019 13:24:10 +0000 (14:24 +0100)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 22 Jun 2019 13:24:10 +0000 (14:24 +0100)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
generate_image.sh

index 373f73c602b900e3e4f7fce5a59923e1516bc08b..3d583f098de14ff53142c24fde8372517fbb259b 100755 (executable)
@@ -239,17 +239,16 @@ get_compression_type() {
 check_for_free_space() {
                local space=${1}
                local path=${2}
+               local space_in_path=0
 
-               # Space needs to passed in MB
-               # df returns bytes so we multiple by 1024
-               space=$(( ${space} * 1024 ))
-
-               log debug $(df --output=avail ${path} | tail -n 1)
+               space_in_path=$(df -h -B MB --output=avail ${path} | tail -n 1)
+               space_in_path=${space_in_path%MB}
+               log debug ${space_in_path}
                log debug ${space}
 
-               if [ $(df --output=avail ${path} | tail -n 1) -lt ${space} ]; then
+               if [ ${space_in_path}  -lt ${space} ]; then
                        log error "Not enough free space available under ${path}"
-                       log error "Free space is $(df -h -B MB --output=avail ${path} | tail -n 1) but we need at least $(( ${space} / 1024 / 1024 ))MB"
+                       log error "Free space is ${space_in_path}MB but we need at least ${space}MB"
                        return ${EXIT_ERROR}
                fi
 }