Skip to content

Commit

Permalink
Added updated mechanism to cyverse-sdk-info
Browse files Browse the repository at this point in the history
  • Loading branch information
mwvaughn committed May 10, 2016
1 parent 3aba679 commit d931dcc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ api_release := 2.1.8
TENANT_NAME := 'Cyverse'
TENANT_KEY := 'iplantc.org'
PREFIX := $(HOME)
SDK_GIT_REPO := 'https://github.com/iPlantCollaborativeOpenSource/cyverse-sdk'
CLI_GIT_REPO := 'https://bitbucket.org/agaveapi/cli'

OBJ = cyverse-cli
SOURCES = customize
Expand All @@ -31,6 +33,7 @@ customize: cli
echo "Customizing..."
cp -fr src/templates $(OBJ)/
cp -fr src/scripts/* $(OBJ)/bin/
cp VERSION $(OBJ)/SDK-VERSION
sed -e 's|$${TENANT_NAME}|$(TENANT_NAME)|g' \
-e 's|$${TENANT_KEY}|$(TENANT_KEY)|g' \
-e 's|$${api_version}|$(api_version)|g' \
Expand Down
36 changes: 36 additions & 0 deletions src/scripts/cyverse-sdk-info
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,39 @@ echo "${TENANT_NAME} CLI v${sdk_version}"
echo "For use with"
echo " Tenant: ${TENANT_KEY}"
echo " Agave API: ${api_version}/${api_release}+"

function do_update {


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

INSTALLED=$(cat $DIR/../SDK-VERSION)
AVAILABLE=$(curl -skL "https://raw.githubusercontent.com/iPlantCollaborativeOpenSource/cyverse-sdk/master/VERSION")
UPDATE_NEEDED=$(awk -v n1=$INSTALLED -v n2=$AVAILABLE 'BEGIN {if (n1<n2) printf ("1"); else printf ("0");}')

function update_cli {

mytmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
curl -skL -o ${mytmpdir}/cyverse-cli.tgz "https://raw.githubusercontent.com/iPlantCollaborativeOpenSource/cyverse-sdk/master/cyverse-cli.tgz"
tar -xf ${mytmpdir}/cyverse-cli.tgz -C "$DIR/../../"
rm -rf ${mytmpdir}
echo "Done."
}

if [ ${UPDATE_NEEDED} -eq 1 ];
then
echo -e "\nUpdating from ${INSTALLED} to ${AVAILABLE}..."
update_cli
else
echo -e "\nThere is no update available."
fi


}

if [ "$1" = "--update" ];
then
do_update
else
echo -e "\nRe-run with --update to check for and install the latest version of the SDK."
fi

0 comments on commit d931dcc

Please sign in to comment.