forked from servian/hashiqube
-
Notifications
You must be signed in to change notification settings - Fork 3
/
boundary.sh
executable file
·51 lines (47 loc) · 2.17 KB
/
boundary.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# https://learn.hashicorp.com/tutorials/boundary/getting-started-install
# https://learn.hashicorp.com/tutorials/boundary/getting-started-dev
function boundary-install() {
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install curl unzip jq
yes | sudo docker system prune -a
yes | sudo docker system prune --volumes
arch=$(lscpu | grep "Architecture" | awk '{print $NF}')
if [[ $arch == x86_64* ]]; then
ARCH="amd64"
elif [[ $arch == aarch64 ]]; then
ARCH="arm64"
fi
echo -e '\e[38;5;198m'"CPU is $ARCH"
# check if waypoint is installed, start and exit
if [ -f /usr/local/bin/boundary ]; then
echo -e '\e[38;5;198m'"++++ Bundary already installed at /usr/local/bin/boundary"
echo -e '\e[38;5;198m'"++++ `/usr/local/bin/boundary version`"
else
# if boundary is not installed, download and install
echo -e '\e[38;5;198m'"++++ Boundary not installed, installing.."
LATEST_URL=$(curl -sL https://releases.hashicorp.com/boundary/index.json | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'rc|beta' | egrep "linux.*$ARCH" | sort -V | tail -n 1)
wget -q $LATEST_URL -O /tmp/boundary.zip
mkdir -p /usr/local/bin
(cd /usr/local/bin && unzip /tmp/boundary.zip)
echo -e '\e[38;5;198m'"++++ Installed `/usr/local/bin/boundary version`"
fi
mkdir -p /etc/boundary
cat <<EOF | sudo tee /etc/boundary/server.conf
listener "tcp" {
purpose = "api"
address = "0.0.0.0:19200"
}
EOF
echo -e '\e[38;5;198m'"++++ Starting Boundary in dev mode"
pkill boundary
sleep 10
pkill boundary
nohup boundary dev -api-listen-address 0.0.0.0:19200 > /var/log/boundary.log 2>&1 &
sh -c 'sudo tail -f /var/log/boundary.log | { sed "/Boundary server started/ q" && kill $$ ;}'
echo -e '\e[38;5;198m'"++++ Boundary Server started at http://localhost:19200"
echo -e '\e[38;5;198m'"++++ Login with admin:password"
echo -e '\e[38;5;198m'"++++ Boundary Documentation http://localhost:3333/#/hashicorp/README?id=boundary"
# TODO: read token and test login
# boundary authenticate password -login-name=admin -password password -auth-method-id=ampw_1234567890 -addr=http://127.0.0.1:19200
}
boundary-install