|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# runs command from parameters and exits with the eoror code of the command |
| 4 | +# if it fails |
| 5 | +function successOrExit { |
| 6 | + "$@" |
| 7 | + local status=$? |
| 8 | + if [ $status -ne 0 ]; then |
| 9 | + echo "$1 exited with error: $status" |
| 10 | + exit $status |
| 11 | + fi |
| 12 | +} |
| 13 | + |
| 14 | +set | grep TRAVIS |
| 15 | + |
| 16 | +test $1 && arg1=$1 |
| 17 | +if [[ $arg1 = 'release' ]]; then |
| 18 | + ver=${ML_VERSION} |
| 19 | + fname=MarkLogic-RHEL6-${ver}.x86_64.rpm |
| 20 | + fnamedeb="marklogic_" |
| 21 | + fnamedeb=$fnamedeb$ver |
| 22 | + suff="_amd64.deb" |
| 23 | + fnamedeb=$fnamedeb$suff |
| 24 | + |
| 25 | + curl -c cookies.txt --data "email=${MLBUILD_USER}&password=${MLBUILD_PASSWORD}" https://developer.marklogic.com/login |
| 26 | + dl_link=$(curl -b cookies.txt --data "download=/download/binaries/8.0/${fname}" https://developer.marklogic.com/get-download-url | perl -pe 's/.*"path":"([^"]+).*/\1/') |
| 27 | + url="https://developer.marklogic.com${dl_link}" |
| 28 | + |
| 29 | + echo "********* Downloading MarkLogic $ver" |
| 30 | + |
| 31 | + successOrExit curl -k -o ./$fname $url |
| 32 | + |
| 33 | + fname=$(pwd)/$fname |
| 34 | + |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install wajig alien rpm lsb-base dpkg-dev debhelper build-essential |
| 37 | + (cd /etc && sudo ln -s default sysconfig) |
| 38 | + sudo wajig rpminstall $fname |
| 39 | + |
| 40 | + echo "********* MarkLogic $ver installed" |
| 41 | +else |
| 42 | + # find today |
| 43 | + day=$(date +"%Y%m%d") |
| 44 | + |
| 45 | + # if the user passed a day string as a param then use it instead |
| 46 | + test $1 && day=$1 |
| 47 | + # make a version number out of the date |
| 48 | + ver="8.0-$day" |
| 49 | + |
| 50 | + echo "********* Downloading MarkLogic nightly $ver" |
| 51 | + |
| 52 | + # fetch/install ML nightly |
| 53 | + fname="MarkLogic-$ver.x86_64.rpm" |
| 54 | + fnamedeb="marklogic_" |
| 55 | + fnamedeb=$fnamedeb$ver |
| 56 | + suff="_amd64.deb" |
| 57 | + fnamedeb=$fnamedeb$suff |
| 58 | + |
| 59 | + url="https://root.marklogic.com/nightly/builds/linux64/rh6-intel64-80-test-1.marklogic.com/b8_0/pkgs.$day/$fname" |
| 60 | + |
| 61 | + status=$(curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD --head --write-out %{http_code} --silent --output /dev/null $url) |
| 62 | + if [[ $status = 200 ]]; then |
| 63 | + successOrExit curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD -o ./$fname $url |
| 64 | + |
| 65 | + fname=$(pwd)/$fname |
| 66 | + |
| 67 | + sudo apt-get update |
| 68 | + sudo apt-get install alien dpkg-dev debhelper build-essential |
| 69 | + sudo alien -d -k $fname |
| 70 | + sudo dpkg -i $fnamedeb |
| 71 | + |
| 72 | + echo "********* MarkLogic nightly $ver installed" |
| 73 | + else |
| 74 | + echo "CANNOT DOWNLOAD: status = $status for date $day (URL=\"$url\")" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | +fi |
0 commit comments