Skip to content

Commit

Permalink
Fix #1151 check if bc command is available (#1201)
Browse files Browse the repository at this point in the history
On some systems the `bc` command is not installed, so I added a check if the command can be used.

It is a simply calculation from KB to GB.  If `bc` is missing, then it is displayed in KB.

fix: #1151
  • Loading branch information
Falke-Design committed Sep 1, 2021
1 parent d205f4a commit 87a37da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "ERR: Sorry this is working only on x86_64!"
exit 1
fi

echo " : --- Memory, CPU info ---- "
mem=$( grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024^2" | bc )
echo "System memory (GB): ${mem}"
if [ -n "$(command -v bc)" ]; then
mem=$( grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024^2" | bc )
echo "System memory (GB): ${mem}"
else
mem=$( grep MemTotal /proc/meminfo | awk '{print $2}')
echo "System memory (KB): ${mem}"
fi
grep SwapTotal /proc/meminfo
echo "CPU number: $(grep -c processor /proc/cpuinfo) x $(grep "bogomips" /proc/cpuinfo | head -1)"
grep Free /proc/meminfo
Expand Down

0 comments on commit 87a37da

Please sign in to comment.