From d1bc844afa0d94123ae1c3a7a294b1bf86a7ff53 Mon Sep 17 00:00:00 2001 From: Kishen V Date: Mon, 23 Sep 2024 11:40:12 +0530 Subject: [PATCH] Fix get.sh to select between --version and version subcommand --- get.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/get.sh b/get.sh index b8f53f9d..402330f9 100755 --- a/get.sh +++ b/get.sh @@ -67,6 +67,17 @@ function check_connectivity() { function install_pvsadm() { + local major=0 + local minor=0 + local patch=0 + if egrep '^v[0-9]+\.[0-9]+\.[0-9]+' <<<"${VERSION}" >/dev/null 2>&1 ; then + local n=${VERSION//[!0-9]/ } + local a=(${n//\./ }) + major=${a[0]} + minor=${a[1]} + patch=${a[2]} + fi + if [[ "${FORCE}" -eq 1 ]]; then if command -v "pvsadm" &> /dev/null; then rm -f /usr/local/bin/pvsadm @@ -75,8 +86,7 @@ function install_pvsadm() { if command -v "pvsadm" &> /dev/null; then echo "pvsadm is already installed!" - # TODO: move to pvsadm --version for future releases. - pvsadm version + print_version $major $minor $patch exit 1 fi @@ -92,7 +102,21 @@ function install_pvsadm() { fi chmod +x /usr/local/bin/pvsadm - pvsadm --version + print_version $major $minor $patch +} + +function print_version() { + # check if version is < 0.1.18, which uses the pvsadm subcommand + local major=$1 + local minor=$2 + local patch=$3 + if [ $major -lt 1 ] && [ $minor -lt 1 ] && [ $patch -lt 18 ]; + then + pvsadm version + # the more recent releases support the version subcommand + else + pvsadm --version + fi } function run (){