Browse Source

support selection of image via `ARMBIAN_IMAGE` env var

The MMGen Project 1 year ago
parent
commit
8e5edf2d07
1 changed files with 5 additions and 2 deletions
  1. 5 2
      scripts/armbian_rootenc_setup.sh

+ 5 - 2
scripts/armbian_rootenc_setup.sh

@@ -70,6 +70,7 @@ print_help() {
   For non-interactive operation, set the following variables in your environment
   For non-interactive operation, set the following variables in your environment
   or on the command line:
   or on the command line:
 
 
+      ARMBIAN_IMAGE      - Armbian image file
       ROOTFS_NAME        - device mapper name of target root filesystem
       ROOTFS_NAME        - device mapper name of target root filesystem
       IP_ADDRESS         - IP address of target (set to 'dhcp' for dynamic IP
       IP_ADDRESS         - IP address of target (set to 'dhcp' for dynamic IP
                            or 'none' to disable remote SSH unlocking support)
                            or 'none' to disable remote SSH unlocking support)
@@ -556,7 +557,7 @@ _clean() {
 get_armbian_image() {
 get_armbian_image() {
 	ARMBIAN_IMAGE="$(echo *.img)"
 	ARMBIAN_IMAGE="$(echo *.img)"
 	[ "$ARMBIAN_IMAGE" != '*.img' ] || die 'No image file found: You must place an Armbian image in the current directory!'
 	[ "$ARMBIAN_IMAGE" != '*.img' ] || die 'No image file found: You must place an Armbian image in the current directory!'
-	local count=$(echo "$ARMBIAN_IMAGE" | wc -l)
+	local count=$(echo "$ARMBIAN_IMAGE" | wc -w)
 	[ "$count" == 1 ] || die "More than one image file present!:\n$ARMBIAN_IMAGE"
 	[ "$count" == 1 ] || die "More than one image file present!:\n$ARMBIAN_IMAGE"
 }
 }
 
 
@@ -1328,7 +1329,9 @@ else
 	SCRIPT_DESC='Host script'
 	SCRIPT_DESC='Host script'
 	_do_header
 	_do_header
 	_set_host_vars
 	_set_host_vars
-	get_armbian_image
+
+	[ "$ARMBIAN_IMAGE" ] || get_armbian_image
+
 	apt_install_host_pkgs # _preclean requires cryptsetup
 	apt_install_host_pkgs # _preclean requires cryptsetup
 	_preclean
 	_preclean