Extract the first numerical output from free --giga
This commit is contained in:
parent
b3802a356e
commit
98e44bbaa8
5
quickemu
5
quickemu
|
@ -320,9 +320,8 @@ function vm_boot() {
|
||||||
local RAM_VM="2G"
|
local RAM_VM="2G"
|
||||||
if [ -z "${ram}" ]; then
|
if [ -z "${ram}" ]; then
|
||||||
local RAM_HOST=""
|
local RAM_HOST=""
|
||||||
RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g')
|
# Determine the number of gigabytes of RAM in the host by extracting the first numerical value from the output.
|
||||||
#Round up - https://github.com/wimpysworld/quickemu/issues/11
|
RAM_HOST=$(free --giga | tr ' ' '\n' | grep -m 1 [0-9])
|
||||||
RAM_HOST=$(printf '%.*f\n' 0 "${RAM_HOST}")
|
|
||||||
if [ "${RAM_HOST}" -ge 128 ]; then
|
if [ "${RAM_HOST}" -ge 128 ]; then
|
||||||
RAM_VM="32G"
|
RAM_VM="32G"
|
||||||
elif [ "${RAM_HOST}" -ge 64 ]; then
|
elif [ "${RAM_HOST}" -ge 64 ]; then
|
||||||
|
|
Loading…
Reference in New Issue