Skip to content

Commit

Permalink
Fix get.sh to select between --version and version subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
kishen-v committed Sep 23, 2024
1 parent 94d368e commit d1bc844
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 (){
Expand Down

0 comments on commit d1bc844

Please sign in to comment.