summaryrefslogtreecommitdiff
path: root/extensions/image-package-example/make-disk-image.sh.in
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-02 14:01:55 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-02 14:01:55 +0000
commitc6abc426b5857f9b1edd9c72e3094c1e2df8a7bf (patch)
treeeff61e6fe9bb3adcf254c4e86eebca7190c65cce /extensions/image-package-example/make-disk-image.sh.in
parent4f43fdd08770c113f7443fecbda43d4316091d4b (diff)
parent02faf51e91a8c55adfbb6d953bca354ab99bf261 (diff)
downloaddefinitions-c6abc426b5857f9b1edd9c72e3094c1e2df8a7bf.tar.gz
Merge branch 'baserock/adamcoldrick/all-exts-in-definitions-v2'
Reviewed-by: Richard Maw <richard.maw@codethink.co.uk>
Diffstat (limited to 'extensions/image-package-example/make-disk-image.sh.in')
-rw-r--r--extensions/image-package-example/make-disk-image.sh.in36
1 files changed, 36 insertions, 0 deletions
diff --git a/extensions/image-package-example/make-disk-image.sh.in b/extensions/image-package-example/make-disk-image.sh.in
new file mode 100644
index 00000000..61264fa0
--- /dev/null
+++ b/extensions/image-package-example/make-disk-image.sh.in
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Script for writing the system to a disk image file.
+# This creates a file of the right size, attaches it to a loop device,
+# then hands the rest of the work off to disk-install.sh
+
+usage(){
+ cat <<EOF
+usage: $0 FILENAME SIZE [TARGET_DISK]
+
+FILENAME: Location to write the disk image to
+SIZE: Size to create the disk image with
+TARGET_DISK: What the disk will appear as on the target machine
+EOF
+}
+
+. @@SCRIPT_DIR@@/common.sh
+
+if [ "$#" -lt 2 -o "$#" -gt 3 ]; then
+ usage
+ exit 1
+fi
+
+DISK_IMAGE="$1"
+DISK_SIZE="$2"
+TARGET_DISK="${3-/dev/vda}"
+
+make_disk_image "$DISK_SIZE" "$DISK_IMAGE"
+
+(
+ LOOP="$(loop_file "$DISK_IMAGE")"
+ set +e
+ @@SCRIPT_DIR@@/disk-install.sh "$DISK_IMAGE" "$TARGET_DISK"
+ ret="$?"
+ unloop_file "$LOOP"
+ exit "$ret"
+)