123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #!/usr/bin/env sh
- # IBM Confidential
- # OCO Source Materials
- # IBM Business Platform: Cognos Analytics on the Cloud
- # (C) Copyright IBM Corp. 2018
- #
- # The source code for this program is not published or otherwise divested of its trade secrets,
- # irrespective of what has been deposited with the U.S. Copyright Office.
- # This script provides access to the Globalization Pipeline
- set -e
- if [ -z "$GPIPE_JAR_REPOSITORY_URL" ]; then
- # fix this by moving to pipeline config
- GPIPE_JAR_REPOSITORY_URL="http://capipeline-nexus.canlab.ibm.com:8081/nexus/repository/master-mvn-dev"
- fi
- if [ -z "$GPIPE_GIT_REPOSITORY_URL" ]; then
- # fix this by moving to pipeline config
- GPIPE_GIT_REPOSITORY_URL="https://github.ibm.com/api/v3/repos/BusinessAnalytics/gp-helper"
- fi
- if [ -z "$GPIPE_JAR" ]; then
- GPIPE_JAR="${HOME}/gpipe.jar"
- fi
- if [ -z "$GPIPE_JAR_VERSION" ]; then
- GPIPE_JAR_VERSION="latest"
- fi
- GPSCRIPT=$0
- function displayUsage() {
- cat << EOF
- updateScript - updates the gpipe script in place. Requires \$GIT_TOKEN or
- \$GIT_API_TOKEN be set.
- updateJar - downloads the latest version of the gpipe jar file to the
- location indicated by \$GPIPE_JAR environment variable. Requires
- \$W3_USERNAME and \$W3_PASSWORD be set.
- Credentials may alternately be set in the netrc file for the hosts
- capipeline-nexus.canlab.ibm.com and github.ibm.com.
- EOF
- }
- function usage() {
- if [ -e $GPIPE_JAR ]; then
- java -cp ${GPIPE_JAR} com.ibm.g11n.pipeline.GPipe help
- fi
- displayUsage
- }
- function getGPScript() {
- if [ -z "$GIT_API_TOKEN" ]; then
- if [ -z "$GIT_TOKEN" ]; then
- CURL_CREDS="-n"
- else
- CURL_CREDS="-u user:$GIT_TOKEN"
- fi
- else
- CURL_CREDS="-u user:$GIT_API_TOKEN"
- fi
- curl --retry 5 --fail --silent --create-dirs $CURL_CREDS -o ${GPSCRIPT}.tags --show-error --location ${GPIPE_GIT_REPOSITORY_URL}/releases/latest
- TAG=$(grep tag_name ${GPSCRIPT}.tags | cut -d'"' -f4)
- rm -f ${GPSCRIPT}.tags
- echo "Downloading version $TAG of gpipe helper script to $GPSCRIPT"
- curl --retry 5 -o ${GPSCRIPT} $CURL_CREDS --fail --silent --create-dirs --show-error --location -H Accept:application/vnd.github.v4.raw ${GPIPE_GIT_REPOSITORY_URL}/contents/gpipe?ref=${TAG}
- exit 1
- }
- function getGPJar() {
- if [ ! -e $GPIPE_JAR ]; then
- if [[ -z "$W3_USERNAME" || -z "$W3_PASSWORD" ]]; then
- CURL_CREDS="-n"
- else
- CURL_CREDS="-u $W3_USERNAME:$W3_PASSWORD"
- fi
- if [ "$GPIPE_JAR_VERSION" == "latest" ]; then
- curl --retry 5 -f -s -S -L $CURL_CREDS -o ${GPIPE_JAR}.versions $GPIPE_JAR_REPOSITORY_URL/com/ibm/g11n/pipeline/gp-cli-with-filters/maven-metadata.xml
- GPIPE_JAR_VERSION=$(grep "<version>" ${GPIPE_JAR}.versions | sed -e 's/</ /g' -e 's/>/ /g' | awk '{ print $2 }' | sort -V | tail -1)
- rm -f ${GPIPE_JAR}.versions
- fi
- echo "Downloading version $GPIPE_JAR_VERSION of GPIPE jar with dependencies to $GPIPE_JAR"
- curl --retry 5 -f $CURL_CREDS -L -S --create-dirs --progress-bar -o $GPIPE_JAR $GPIPE_JAR_REPOSITORY_URL/com/ibm/g11n/pipeline/gp-cli-with-filters/${GPIPE_JAR_VERSION}/gp-cli-with-filters-${GPIPE_JAR_VERSION}.jar
- else
- echo "$GPIPE_JAR exists. Download aborted."
- fi
- }
- if [ "$1" == "" ]
- then
- usage
- exit 0
- fi
- while (( "$#" ))
- do
- case "$1" in
- help)
- usage;
- exit 0
- ;;
- updateScript)
- getGPScript;
- ;;
- updateJar)
- getGPJar;
- ;;
- *)
- java -cp ${GPIPE_JAR} com.ibm.g11n.pipeline.GPipe $@
- exit 0
- ;;
- esac
- shift
- done
|