summaryrefslogtreecommitdiff
path: root/setup-consul-env.sh
blob: a8a8dd883491d03b7de8141cac49eb8a7a4f927e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -eux

if [ -z "$(which consul)" ]; then
    # originally we used 0.6.3 (released in Jan 2016).
    # updated to 1.7.4 in Change-Id: Iaddf21f14c434129541e7c9ec7134e0661f7be52
    # 1.4.0 (released Nov 2018) has a new ACL system.
    # 1.6.1 (released Sep 2019) is the version used by python-consul2 for testing.
    # 1.7.0 (released Feb 2020) changes standards enforcement.
    # For details see upgrade notes in Change-Id: I98fc96468b21368ce66365e3fc38c495b1f2918a
    CONSUL_VERSION=1.7.4
    CONSUL_RELEASE_URL=https://releases.hashicorp.com/consul
    case `uname -s` in
        Darwin)
            consul_file="consul_${CONSUL_VERSION}_darwin_amd64.zip"
            ;;
        Linux)
            consul_file="consul_${CONSUL_VERSION}_linux_amd64.zip"
            ;;
        *)
            echo "Unknown operating system"
            exit 1
            ;;
    esac
    consul_dir=`basename $consul_file .zip`
    mkdir -p $consul_dir
    curl -L $CONSUL_RELEASE_URL/$CONSUL_VERSION/$consul_file > $consul_dir/$consul_file
    unzip $consul_dir/$consul_file -d $consul_dir
    export PATH=$PATH:$consul_dir
fi

# Yield execution to venv command
$*