Skip to content

Commit 75fc688

Browse files
author
Prakash Surya
authored
Automatically determine image variant if not specified (#241)
This change optimizes the UX of "download-latest-image" script, such that the user does not necessarily have to specify the image variant to be downloaded. This is useful for the case where the script is run on an existing Delphix appliance, and the user wants the script to download the image variant that matches the appliance it's being run on. In this case, the script can (and now does, with this change) detect the variant of the appliance, and download the corresponding image, without forcing the user to specify which variant to download.
1 parent 339d20d commit 75fc688

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

files/common/usr/bin/download-latest-image

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function die() {
2222

2323
function usage() {
2424
echo "$(basename "$0"): $*" >&2
25-
echo "Usage: $(basename "$0") [-f] [-N] [-b branch] <variant>"
25+
echo "Usage: $(basename "$0") [-f] [-N] [-b branch] [variant]"
2626
exit 2
2727
}
2828

@@ -43,11 +43,19 @@ done
4343
shift $((OPTIND - 1))
4444

4545
[[ $# -gt 1 ]] && usage "too many arguments specified"
46-
[[ $# -eq 0 ]] && usage "too few arguments specified"
4746

4847
$opt_f && rm -f "latest" >/dev/null 2>&1
4948
[[ -f "latest" ]] && die "file 'latest' already exists"
5049

50+
VARIANT="$1"
51+
if [[ -z "$VARIANT" ]]; then
52+
PLATFORM=$(cat "/var/lib/delphix-appliance/platform")
53+
[[ -n "$PLATFORM" ]] || die "platform could not be determined"
54+
55+
VARIANT=$(cat "/usr/share/doc/delphix-entire-$PLATFORM/variant")
56+
[[ -n "$VARIANT" ]] || die "variant could not be determined"
57+
fi
58+
5159
#
5260
# We don't want to delete the "latest" file if it already exists and the
5361
# "-f" option isn't specified, so we need to be careful to register this
@@ -69,8 +77,8 @@ aws s3 cp \
6977
"s3://snapshot-de-images/builds/jenkins-ops/devops-gate/master/appliance-build/$opt_b/$build/latest" \
7078
. || die "failed to download file: 'latest'"
7179

72-
$opt_f && rm -f "$1.upgrade.tar" >/dev/null 2>&1
73-
[[ -f "$1.upgrade.tar" ]] && die "image $1.upgrade.tar already exists"
80+
$opt_f && rm -f "$VARIANT.upgrade.tar" >/dev/null 2>&1
81+
[[ -f "$VARIANT.upgrade.tar" ]] && die "image $VARIANT.upgrade.tar already exists"
7482

75-
aws s3 cp "s3://snapshot-de-images/$(cat latest)/upgrade-artifacts/$1.upgrade.tar" . ||
76-
die "failed to download file: '$1.upgrade.tar'"
83+
aws s3 cp "s3://snapshot-de-images/$(cat latest)/upgrade-artifacts/$VARIANT.upgrade.tar" . ||
84+
die "failed to download file: '$VARIANT.upgrade.tar'"

0 commit comments

Comments
 (0)