Extract verify-configuration.sh from setup-teslausb

This commit is contained in:
cimryan
2018-11-02 22:44:28 -07:00
parent bab44a79b7
commit fe7ab50ab1
2 changed files with 35 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
#!/bin/bash -eu
function check_variable () {
local var_name="$1"
if [ -z "${!var_name+x}" ]
then
setup_progress "STOP: Define the variable $var_name like this: export $var_name=value"
exit 1
fi
}
function check_available_space () {
setup_progress "Verifying that there is sufficient space available on the MicroSD card..."
local available_space="$( parted -m /dev/mmcblk0 u b print free | tail -1 | cut -d ":" -f 4 | sed 's/B//g' )"
if [ "$available_space" -lt 4294967296 ]
then
setup_progress "STOP: The MicroSD card is too small."
exit 1
fi
setup_progress "There is sufficient space available."
}
check_variable "campercent"
check_available_space