-
Notifications
You must be signed in to change notification settings - Fork 59
/
tools.sh
executable file
·188 lines (152 loc) · 5.96 KB
/
tools.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env bash
set -o errexit
#set -o verbose
#set -o xtrace
set -o nounset
SN_NETWORK_ACCOUNT_PASSWORD=${SN_NETWORK_ACCOUNT_PASSWORD:=no_password_set}
export SN_NETWORK_ACCOUNT_PASSWORD
case "$1" in
# Deploys the Smart Contracts in agent/sn_agent/network/ethereum/core to the specififed network via a
# dockerized version of the Truffle environment and copies the compiled code and deployed addresses to
# the docker/agent/data/dev directory where the Agent's web3.py network class can find it.
deploy-contracts)
DOCKERNET=$(docker network ls | grep dockernet | awk '{print $2}')
if [ "$DOCKERNET" != "dockernet" ]
then
echo "Starting docker network: dockernet"
docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 dockernet
else
echo "Docker network 'dockernet' already running."
fi
echo ""
HOST_OS=$(uname)
echo "HOST_OS = '$HOST_OS'"
if [ "$HOST_OS" == "Darwin" ]
then
echo "Using Truffle network - docker_host_mac"
TRUFFLE_NETWORK=docker_host_mac
else
echo "Using Truffle network - docker_host"
TRUFFLE_NETWORK=docker_host
fi
export TRUFFLE_NETWORK
echo "TRUFFLE_NETWORK = '$TRUFFLE_NETWORK'"
docker-compose -f docker/docker-compose.dev.yml create --build truffle
docker-compose -f docker/docker-compose.dev.yml run --service-ports truffle
;;
# The main developer command for testing and bring up a developer agent
dev)
docker-compose -f docker/docker-compose.dev.yml create --build dev
docker-compose -f docker/docker-compose.dev.yml run --service-ports dev ./agent.sh run
;;
# Rebuilds the dev image in case of stale docker caches
dev-force-build)
docker-compose -f docker/docker-compose.dev.yml create --build --force-recreate dev
;;
# Builds the image only but does not run ig
dev-build)
docker-compose -f docker/docker-compose.dev.yml create --build dev
;;
# Just run the built image.
dev-run)
docker-compose -f docker/docker-compose.dev.yml run --service-ports dev ./agent.sh run
;;
# Take down all the dev containers - defined in docker/docker-compose-dev.yml
dev-down)
docker-compose -f docker/docker-compose.dev.yml down --remove-orphans
;;
# ABC - Alice, Bob and Charlie (she's a girl)
# Brings up the Alice server fo demonstrate many agents interacting.
alice)
docker-compose -f docker/docker-compose.abc.yml create --build alice
docker-compose -f docker/docker-compose.abc.yml run --service-ports alice ./agent.sh run
;;
# Brings up Bob
bob)
docker-compose -f docker/docker-compose.abc.yml create --build bob
docker-compose -f docker/docker-compose.abc.yml run --service-ports bob ./agent.sh run
;;
# Brings up Charlie - she likes to be last...
charlie)
docker-compose -f docker/docker-compose.abc.yml create --build charlie
docker-compose -f docker/docker-compose.abc.yml run --service-ports charlie ./agent.sh run
;;
demo)
docker-compose -f docker/docker-compose.demo.yml create --build --force-recreate demo
docker-compose -f docker/docker-compose.demo.yml run --service-ports demo ./agent.sh run
;;
demo-down)
docker-compose -f docker/docker-compose.demo.yml down --remove-orphans
;;
# Experimental code - don't count on this staying around
opendht)
docker-compose -f docker/docker-compose.yml create --build --force-recreate opendht
docker-compose -f docker/docker-compose.yml run --service-ports opendht
;;
geth)
docker-compose -f docker/docker-compose.yml create --build --force-recreate geth
docker-compose -f docker/docker-compose.yml run --service-ports geth $2
;;
solc)
docker-compose -f docker/docker-compose.yml run --service-ports geth solc --help
;;
parity)
docker-compose -f docker-compose.dev.yml create --build --force-recreate parity
docker-compose -f docker-compose.dev.yml run --service-ports parity $2
;;
vault)
docker-compose -f docker/docker-compose.yml create --build --force-recreate vault
docker-compose -f docker/docker-compose.yml run --service-ports vault $2
;;
ipfs)
docker-compose -f docker/docker-compose.yml run --service-ports ipfs daemon
;;
init)
#https://www.vaultproject.io/intro/getting-started/deploy.html#initializing-the-vault+
;;
# Support
# Builds the docs
agent-docs)
docker-compose -f docker/docker-compose.yml create --build test
docker-compose -f docker/docker-compose.ymlrun test ./agent.sh docs
;;
# Runs the test suite
agent-test)
docker-compose -f docker/docker-compose.yml start testrpc
docker-compose -f docker/docker-compose.yml create --build test
docker-compose -f docker/docker-compose.yml run test ./agent.sh test
;;
# Brings up the OpenCog relationship extracter node
relex)
docker-compose -f docker/docker-compose.dev.yml run --service-ports relex
;;
# A test Ethereum client RPC server (ganache-cli) docker image
testrpc)
docker-compose -f docker/docker-compose.yml create --build testrpc
docker-compose -f docker/docker-compose.yml run --service-ports testrpc
;;
# Cleans recent docker images... useful when working on docker-compose and Dockerfiles
clean)
docker-compose -f docker/docker-compose.yml down --rmi all --remove-orphans
;;
# Clears the entire docker cache - generally only necessary when doing work with Dockerfiles themselves
hard-clean)
docker image prune
docker-compose -f docker/docker-compose.dev.yml down --rmi all --remove-orphans
docker-compose -f docker/docker-compose.yml down --rmi all --remove-orphans
docker kill `docker ps -q` || true
docker rm `docker ps -a -q`
docker rmi `docker images -q`
docker volume rm `docker volume ls -qf dangling=true`
;;
create-web-cookie)
docker-compose -f docker/docker-compose.yml run agent-web-cookie
;;
gen-ssl)
cd agent
openssl req -nodes -new -x509 -keyout server.key -out server.crt -subj '/CN=localhost'
;;
*) echo "Command '$1' not found - No operation specified"
exit 0;
;;
esac