mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Extract verify-configuration.sh from setup-teslausb
This commit is contained in:
@@ -102,6 +102,12 @@ function check_available_space () {
|
|||||||
setup_progress "There is sufficient space available."
|
setup_progress "There is sufficient space available."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verify_configuration () {
|
||||||
|
get_script /tmp verify-configuration.sh setup/pi
|
||||||
|
|
||||||
|
/tmp/verify-configuration.sh
|
||||||
|
}
|
||||||
|
|
||||||
function get_script () {
|
function get_script () {
|
||||||
local local_path="$1"
|
local local_path="$1"
|
||||||
local name="$2"
|
local name="$2"
|
||||||
@@ -195,9 +201,7 @@ headless_setup_progress_flash 1
|
|||||||
|
|
||||||
setup_progress "Verifying that the requested configuration is valid..."
|
setup_progress "Verifying that the requested configuration is valid..."
|
||||||
|
|
||||||
check_variable "campercent"
|
verify_configuration
|
||||||
|
|
||||||
check_available_space
|
|
||||||
|
|
||||||
# Flash for Stage 3 headless (grab scripts)
|
# Flash for Stage 3 headless (grab scripts)
|
||||||
headless_setup_progress_flash 2
|
headless_setup_progress_flash 2
|
||||||
|
|||||||
28
setup/pi/verify-configuration.sh
Normal file
28
setup/pi/verify-configuration.sh
Normal 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
|
||||||
Reference in New Issue
Block a user