summaryrefslogtreecommitdiff
path: root/imgpkg/make-disk-image.sh.in
blob: 29a0e13a11d59e296961a1d6a47b7271a6f2919b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/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"
)