|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# set default value of DOCKER_HOST and BRANCH |
| 4 | +if [[ "$DOCKER_HOST" == "" ]];then |
| 5 | + DOCKER_HOST="tcp://us-west-1.hyper.sh:443" |
| 6 | +fi |
| 7 | +if [[ "$BRANCH" == "" ]];then |
| 8 | + BRANCH="master" |
| 9 | +fi |
| 10 | + |
| 11 | + |
| 12 | +if [[ "$@" != "./build.sh" ]];then |
| 13 | + #ensure config for hyper cli |
| 14 | + mkdir -p ~/.hyper |
| 15 | + cat > ~/.hyper/config.json <<EOF |
| 16 | +{ |
| 17 | + "clouds": { |
| 18 | + "${DOCKER_HOST}": { |
| 19 | + "accesskey": "${ACCESS_KEY}", |
| 20 | + "secretkey": "${SECRET_KEY}" |
| 21 | + } |
| 22 | + } |
| 23 | +} |
| 24 | +EOF |
| 25 | + |
| 26 | +env |
| 27 | + |
| 28 | +echo "========== config git proxy ==========" |
| 29 | +if [ "${http_proxy}" != "" ];then |
| 30 | + git config --global http.proxy ${http_proxy} |
| 31 | +fi |
| 32 | +if [ "${https_proxy}" != "" ];then |
| 33 | + git config --global https.proxy ${https_proxy} |
| 34 | +fi |
| 35 | +git config --list | grep proxy |
| 36 | + |
| 37 | +echo "========== Clone hypercli repo ==========" |
| 38 | +mkdir -p /go/src/github.com/{hyperhq,docker} |
| 39 | +cd /go/src/github.com/hyperhq |
| 40 | +git clone https://github.com/hyperhq/hypercli.git |
| 41 | + |
| 42 | +echo "========== Build hypercli ==========" |
| 43 | +cd /go/src/github.com/hyperhq/hypercli |
| 44 | +git checkout $BRANCH |
| 45 | +if [[ $? -ne 0 ]];then |
| 46 | + echo "Branch $BRANCH not exist!" |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | +./build.sh |
| 50 | +ln -s /go/src/github.com/hyperhq/hypercli /go/src/github.com/docker/docker |
| 51 | +ln -s /go/src/github.com/hyperhq/hypercli/hyper/hyper /usr/bin/hyper |
| 52 | +echo alias hypercli=\"hyper -H \${DOCKER_HOST}\" >> /root/.bashrc |
| 53 | +source /root/.bashrc |
| 54 | + |
| 55 | +echo "##############################################################################################" |
| 56 | +echo "## Welcome to integration test env ##" |
| 57 | +echo "##############################################################################################" |
| 58 | +#show config for hyper cli |
| 59 | +echo "Current hyper config: ~/.hyper/config.json" |
| 60 | +echo "----------------------------------------------------------------------------------------------" |
| 61 | +cat ~/.hyper/config.json \ |
| 62 | + | sed 's/"secretkey":.*/"secretkey": "******************************"/g' \ |
| 63 | + | sed 's/"auth":.*/"auth": "******************************"/g' |
| 64 | +echo "----------------------------------------------------------------------------------------------" |
| 65 | + |
| 66 | +fi |
| 67 | + |
| 68 | +#execute command |
| 69 | +if [[ $# -ne 0 ]];then |
| 70 | + cd /go/src/github.com/hyperhq/hypercli/integration-cli && eval $@ |
| 71 | + if [[ "$@" == "./build.sh" ]];then |
| 72 | + #show make result |
| 73 | + if [[ $? -eq 0 ]];then |
| 74 | + echo "OK:)" |
| 75 | + else |
| 76 | + echo "Failed:(" |
| 77 | + fi |
| 78 | + fi |
| 79 | +fi |
0 commit comments