From 889fa8f9e112a4b3c40c07f34899135813027672 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 27 Dec 2018 15:21:40 +0000 Subject: [PATCH] do not try to resize if it doesn't fit --- system/sbin/kazoo-kamailio | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/system/sbin/kazoo-kamailio b/system/sbin/kazoo-kamailio index 675f369..df7c0f0 100755 --- a/system/sbin/kazoo-kamailio +++ b/system/sbin/kazoo-kamailio @@ -73,23 +73,24 @@ prepare() { rm -rf ${DB_LOCATION}/../db-backup-temp elif [ $mountcurrentsize -gt $mountwantedsize ]; then # check if it fits - echo "wanted size of $mountwantedsize is below current size of $mountcurrentsize , remounting" + echo "wanted size of $mountwantedsize is below current size of $mountcurrentsize , checking sizes" mountusedsize=$(mount_point_used_size) requiredsize=$(( mountusedsize * (100 + ${RAM_DISK_FREE_SIZE_PERC}) / 100)) if [ $requiredsize -gt $mountwantedsize ]; then - echo "wanted size of $mountwantedsize doesn't have enough space for required size of $requiredsize , setting to $requiredsize" + echo "wanted size of $mountwantedsize doesn't have enough space for required size of $requiredsize" mountwantedsize=$requiredsize + else + echo "resizing from $mountcurrentsize to $mountwantedsize" + rm -rf ${DB_LOCATION}/../db-backup-temp + mkdir -p ${DB_LOCATION}/../db-backup-temp + cp -f ${DB_LOCATION}/* ${DB_LOCATION}/../db-backup-temp/ + umount ${DB_LOCATION} + rm -rf ${DB_LOCATION} + mkdir -p ${DB_LOCATION} + mount -t tmpfs -o size=$mountwantedsize tmpfs ${DB_LOCATION} + cp -f ${DB_LOCATION}/../db-backup-temp/* ${DB_LOCATION}/ + rm -rf ${DB_LOCATION}/../db-backup-temp fi - echo "resizing from $mountcurrentsize to $mountwantedsize" - rm -rf ${DB_LOCATION}/../db-backup-temp - mkdir -p ${DB_LOCATION}/../db-backup-temp - cp -f ${DB_LOCATION}/* ${DB_LOCATION}/../db-backup-temp/ - umount ${DB_LOCATION} - rm -rf ${DB_LOCATION} - mkdir -p ${DB_LOCATION} - mount -t tmpfs -o size=$mountwantedsize tmpfs ${DB_LOCATION} - cp -f ${DB_LOCATION}/../db-backup-temp/* ${DB_LOCATION}/ - rm -rf ${DB_LOCATION}/../db-backup-temp fi fi else