From 6c18469854f3fd17b6cf7e6135a9cdc7f7cb9e3a 2017-01-06 23:20:34 From: drtyhlpr Date: 2017-01-06 23:20:34 Subject: [PATCH] Added: Configuration template file support (testing) --- diff --git a/functions.sh b/functions.sh index 4c05259..c8f1b16 100644 --- a/functions.sh +++ b/functions.sh @@ -42,3 +42,14 @@ install_exec() { # Install file with root exec permissions install -o root -g root -m 744 $* } + +use_template () { + # Test if configuration template file exists + if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then + echo "error: configuration template ${CONFIG_TEMPLATE} not found" + exit 1 + fi + + # Load template configuration parameters + . "./templates/${CONFIG_TEMPLATE}" +} diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index b1a2455..5cb9d23 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -30,6 +30,11 @@ fi # Load utility functions . ./functions.sh +# Load parameters from configuration template file +if [ ! -z "$CONFIG_TEMPLATE" ] ; then + use_template +fi + # Introduce settings set -e echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n" diff --git a/templates/rpi2jessie b/templates/rpi2jessie new file mode 100644 index 0000000..c4d27dd --- /dev/null +++ b/templates/rpi2jessie @@ -0,0 +1,2 @@ +# Configuration template file used by rpi23-gen-image.sh +RELEASE=jessie diff --git a/templates/rpi2stretch b/templates/rpi2stretch new file mode 100644 index 0000000..a67c72f --- /dev/null +++ b/templates/rpi2stretch @@ -0,0 +1,3 @@ +# Configuration template file used by rpi23-gen-image.sh +RELEASE=stretch +BUILD_KERNEL=true diff --git a/templates/rpi3jessie b/templates/rpi3jessie new file mode 100644 index 0000000..6a4f72f --- /dev/null +++ b/templates/rpi3jessie @@ -0,0 +1,4 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=3 +RELEASE=jessie +BUILD_KERNEL=true diff --git a/templates/rpi3stretch b/templates/rpi3stretch new file mode 100644 index 0000000..70a063e --- /dev/null +++ b/templates/rpi3stretch @@ -0,0 +1,4 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=3 +RELEASE=stretch +BUILD_KERNEL=true