Skip to content

Instantly share code, notes, and snippets.

@stbenjam
Created July 11, 2016 19:49
Show Gist options
  • Save stbenjam/437c4359a8c9d3af2a6a5f1f1e5d8415 to your computer and use it in GitHub Desktop.
Save stbenjam/437c4359a8c9d3af2a6a5f1f1e5d8415 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# get memory in kilobytes and store it
output = %x(free)
min_ram = 8388608
# grab the total column and store it
free_ram = output.split(" ")[7].to_i
# define error message if less than 8 GB of ram
MEM_SIZE = "This system has less than 8 GB of total memory. Please have at least 8 GB of total ram free before running the installer."
# define our error message method to write to stderr and exit
def error_exit(message, code)
$stderr.puts message
exit code
end
# provide our error to the user if ram is less than 8 GB
error_exit(MEM_SIZE, 1) if output < min_ram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment