Parse free and fdisk output with C locale

some vps providers seem to set a different locale by default.
Settings LC_ALL overrides all the other LC_*
This commit is contained in:
Girish Ramakrishnan
2017-03-13 10:32:27 -07:00
parent 717953c162
commit 3fdc10c523
2 changed files with 4 additions and 4 deletions

View File

@@ -21,9 +21,9 @@ readonly MINIMUM_MEMORY="980" # this is mostly reported for 1GB main memory
readonly curl="curl --fail --connect-timeout 20 --retry 10 --retry-delay 2 --max-time 2400"
# copied from cloudron-resize-fs.sh
readonly physical_memory=$(free -m | awk '/Mem:/ { print $2 }')
readonly physical_memory=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }')
readonly disk_device="$(for d in $(find /dev -type b); do [ "$(mountpoint -d /)" = "$(mountpoint -x $d)" ] && echo $d && break; done)"
readonly disk_size_bytes=$(fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ printf $5 }')
readonly disk_size_bytes=$(LC_ALL=C fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ printf $5 }')
readonly disk_size_gb=$((${disk_size_bytes}/1024/1024/1024))
# verify the system has minimum requirements met