From f6682dabf6b6ea0f8c786a0fd4d7cffa82da4f35 Mon Sep 17 00:00:00 2001 From: deajan Date: Fri, 18 Nov 2016 12:49:48 +0100 Subject: [PATCH] Fixed CheckDiskSpace compat on CentOS 5 --- dev/n_osync.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dev/n_osync.sh b/dev/n_osync.sh index b656c9f..d02986d 100755 --- a/dev/n_osync.sh +++ b/dev/n_osync.sh @@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.2-beta3 -PROGRAM_BUILD=2016111704 +PROGRAM_BUILD=2016111801 IS_STABLE=no # Execution order #__WITH_PARANOIA_DEBUG @@ -284,15 +284,24 @@ function _CheckDiskSpaceLocal { Logger "Checking minimum disk space in [$replica_path]." "NOTICE" - diskSpace=$(df "$replica_path" | tail -1 | awk '{print $4}') - - # Ugly fix for df in some busybox environments that can only show human formats - if [ $(IsInteger $diskSpace) -eq 0 ]; then - diskSpace=$(HumanToNumeric $diskSpace) + # Check for -P portability switch + if df -P; then + diskSpace=$(df -P "$replica_path" | tail -1 | awk '{print $4}') + else + diskSpace=$(df "$replica_path" | tail -1 | awk '{print $4}') fi - if [ $diskSpace -lt $MINIMUM_SPACE ]; then - Logger "There is not enough free space on replica [$replica_path] ($diskSpace KB)." "WARN" + if [ $? != 0 ]; then + Logger "Cannot get free space." "ERROR" + else + # Ugly fix for df in some busybox environments that can only show human formats + if [ $(IsInteger $diskSpace) -eq 0 ]; then + diskSpace=$(HumanToNumeric $diskSpace) + fi + + if [ $diskSpace -lt $MINIMUM_SPACE ]; then + Logger "There is not enough free space on replica [$replica_path] ($diskSpace KB)." "WARN" + fi fi }