Skip to content

Commit

Permalink
Merge pull request #674 from kishen-v/fix-get-version
Browse files Browse the repository at this point in the history
Fix get.sh to select between --version and version subcommand
  • Loading branch information
Power Cloud Robot authored Sep 23, 2024
2 parents 94d368e + 71be465 commit d2d3bd1
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ function check_connectivity() {

function install_pvsadm() {

local major=0
local minor=0
local patch=0

if [[ "$VERSION" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=${BASH_REMATCH[3]}
fi

if [[ "${FORCE}" -eq 1 ]]; then
if command -v "pvsadm" &> /dev/null; then
rm -f /usr/local/bin/pvsadm
Expand All @@ -75,8 +85,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 +101,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.17, which uses the pvsadm subcommand
local major=$1
local minor=$2
local patch=$3
if [ $major -lt 1 ] && [ $minor -lt 2 ] && [ $patch -lt 17 ];
then
pvsadm version
# the more recent releases support the version flag
else
pvsadm --version
fi
}

function run (){
Expand Down

0 comments on commit d2d3bd1

Please sign in to comment.