-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup
executable file
·88 lines (77 loc) · 3.15 KB
/
setup
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
#!/bin/bash
#
# Copyright 2017-2019 Government of Canada - Public Services and Procurement Canada - buyandsell.gc.ca
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
export PIPENV_MAX_DEPTH=16
export RUST_LOG=error
if [[ "${EUID}" -ne 0 ]]
then
echo "Error: please run ${BASH_SOURCE[0]} as sudo"
echo
exit 1
fi
DIR_VON_BASE="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
DIR_VON=$(dirname "${DIR_VON_BASE}") # container for von_base/, von_anchor/ holds pipenv virtual environment
DIR_FILES="${DIR_VON_BASE}/files"
OPERATOR=${SUDO_USER}
PY_VER=${1:-3.6}
# prerequisites
apt clean
rm -r /var/lib/apt/lists/*
apt-get install software-properties-common
bash -c "LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php"
bash -c "LC_ALL=C.UTF-8 add-apt-repository -y ppa:deadsnakes/ppa"
apt update -y && apt install -y build-essential pkg-config cmake libssl-dev libsqlite3-dev libsodium-dev libkrb5-dev libpgm-dev libnorm-dev libzmq3-dev libncursesw5-dev python3.6 python3.6-dev python3-pip python3-nacl apt-transport-https ca-certificates curl libtool autoconf automake uuid-dev jq
# docker
update-ca-certificates
systemctl daemon-reload
if [[ -z "$(which docker)" ]]
then
curl -fsSL https://get.docker.com | sh
usermod -a -G docker ${OPERATOR}
fi
# build docker networks
NETWORK=$(docker network ls --filter name=indy_pool_network | sed '1,1d' | wc -l)
if [[ "${NETWORK}" -eq "0" ]]
then
sudo -u ${OPERATOR} docker network create --subnet 10.0.0.0/24 indy_pool_network
fi
# (von_conx is a dormant project)
# NETWORK=$(docker network ls --filter name=von_conx_network | sed '1,1d' | wc -l)
# if [[ "${NETWORK}" -eq "0" ]]
# then
# sudo -u ${OPERATOR} docker network create --subnet 10.0.1.0/24 von_conx_network
# fi
# build indy_pool_net docker image
INDY_POOL=$(docker images --filter reference=indy_pool | sed '1,1d' | wc -l)
if [[ "${INDY_POOL}" -eq "0" ]]
then
sudo -u ${OPERATOR} docker build --build-arg pool_ip=10.0.0.2 -f "${DIR_FILES}/indy-pool.dockerfile" -t indy_pool .
fi
# install libindy.so
cd "${DIR_FILES}"
tar -xpvzf libindy.so.tgz &> /dev/null
mv libindy.so /usr/lib/
# docker-compose
DC_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
ARCH="$(uname -s)-$(uname -m)"
DC_DEST=/usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DC_VERSION}/docker-compose-${ARCH} > ${DC_DEST}
chmod 755 ${DC_DEST}
curl -L https://raw.githubusercontent.com/docker/compose/${DC_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
# python virtual environment (setup as non-sudo)
cd "${DIR_VON}"
sudo -u ${OPERATOR} -i "${DIR_VON_BASE}/setup-pipenv" "${PY_VER}"
cd -