-
Notifications
You must be signed in to change notification settings - Fork 1
/
sigsci_osx.sh
executable file
·88 lines (75 loc) · 2.12 KB
/
sigsci_osx.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
brew=$(which brew)
if [ -z "$brew" ];
then
echo "Homebrew not found. Please install Homebrew."
exit;
fi
docker=$(which docker)
if [ -z "$docker" ];
then
echo "Docker not found. Installing docker..."
brew install docker
fi
dockermachine=$(which docker-machine)
if [ -z "$dockermachine" ];
then
echo "Docker-machine not found. Installing docker-machine."
brew install docker-machine
fi
dockerimage=$(docker-machine ls | grep sigsci)
if [ "$dockerimage" = "" ];
then
echo "Sigsci docker image not found. Creating Docker image..."
docker-machine create --driver virtualbox --virtualbox-disk-size 2048 --virtualbox-memory 1024 sigsci
fi
echo "Starting Signal Sciences Docker"
if [ -z "$SIGSCI_ACCESSKEYID" ];
then
echo "Please set your SIGSCI_ACCESSKEYID"
echo "e.g. export SIGSCI_ACCESSKEYID=<key>"
exit;
fi
if [ -z "$SIGSCI_SECRETACCESSKEY" ];
then
echo "Please set your SIGSCI_SECRETACCESSKEY"
echo "e.g. export SIGSCI_SECRETACCESSKEY=<key>"
exit;
fi
if [ -z "$SIGSCI_WEBAPP_HOST" ];
then
SIGSCI_WEBAPP_HOST=$(ipconfig getifaddr en0)
fi
if [ -z "$SIGSCI_WEBAPP_PORT" ];
then
SIGSCI_WEBAPP_PORT="8080"
fi
if [ -z "$SIGSCI_AGENT_PORT" ];
then
SIGSCI_AGENT_PORT="80"
fi
eval "$(docker-machine env sigsci)"
docker build -t sigsci-agent:latest .
if [ "$1" == "sidecar" ];
then
echo "Starting agent as sidecar"
export SIGSCI_RPC_ADDRESS="0.0.0.0:9999"
docker run \
-i \
-p "9999:9999" \
-e SIGSCI_ACCESSKEYID="$SIGSCI_ACCESSKEYID" \
-e SIGSCI_SECRETACCESSKEY="$SIGSCI_SECRETACCESSKEY" \
-e SIGSCI_RPC_ADDRESS="$SIGSCI_RPC_ADDRESS" \
-t sigsci-agent:latest
else
docker run \
-i \
-p "$SIGSCI_AGENT_PORT:80" \
--add-host="my.mac.localhost:$SIGSCI_WEBAPP_HOST" \
-e SIGSCI_ACCESSKEYID="$SIGSCI_ACCESSKEYID" \
-e SIGSCI_SECRETACCESSKEY="$SIGSCI_SECRETACCESSKEY" \
-e SIGSCI_REVERSE_PROXY="true" \
-e SIGSCI_REVERSE_PROXY_LISTENER="0.0.0.0:80" \
-e SIGSCI_REVERSE_PROXY_UPSTREAM="my.mac.localhost:$SIGSCI_WEBAPP_PORT" \
-t sigsci-agent:latest
fi