diff --git a/Makefile b/Makefile index 2e9158e..6a765e6 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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' \ diff --git a/src/scripts/cyverse-sdk-info b/src/scripts/cyverse-sdk-info index 0b7133d..34b3ad7 100644 --- a/src/scripts/cyverse-sdk-info +++ b/src/scripts/cyverse-sdk-info @@ -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/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