-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-server.sh
161 lines (151 loc) · 6.96 KB
/
single-server.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
#!/bin/bash
# Install Docker
if ! command -v docker &>/dev/null; then
echo Installing Docker
sudo apt-get update
sudo apt-get install ca-certificates curl wget gnupg byobu git make -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
fi
# Login to Docker
docker_login=$(docker info 2>&1 | grep -i 'Username:')
if ! [[ -n "$docker_login" ]]; then
docker login
fi
# Add SSH key to github
if ! [[ -f "$HOME/.ssh/id_rsa" ]]; then
ssh-keygen -q -t rsa -N "" -f $HOME/.ssh/id_rsa
fi
cat $HOME/.ssh/id_rsa.pub
echo Please add this ssh public key to github
echo "Press Enter to continue..."
read
if ! command -v go &>/dev/null; then
wget https://go.dev/dl/go1.20.6.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz
rm go1.20.6.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bashrc
source $HOME/.bashrc
desired_config="https://github.com/"
# set gitconfig
current_config=$(git config --global --get url.git@github.com:.insteadOf)
if ! [ "$current_config" == "$desired_config" ]; then
git config --global url.git@github.com:.insteadOf "https://github.com/"
echo "Git configuration set to the desired value."
fi
export GOPRIVATE="github.com"
go install github.com/onlicorp/dev-tools/creds@latest
fi
echo Stopping docker containers
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker network create deployment
cd
mkdir -p onlicorp
cd $HOME/onlicorp
# Clone/Update repos
services=(user-tray appliance-tray security-tray proof-engine vault-oracle oracle convey logistics onli-cloud-tray transfer-agent treasury bill-breaker cloud-vault-tray)
for service in "${services[@]}"; do
echo Cloning $service
if [ -d $service ]; then
cd $service
git pull
else
git clone --quiet --depth 1 git@github.com:onlicorp/$service.git
cd $service
fi
cd $HOME/onlicorp
done
# Start byobu session
byobu new-session -d -s os
# user-tray
byobu rename-window "user-tray"
byobu send-keys -t os:0 "cd user-tray" Enter
byobu send-keys -t os:0 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:0 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:0 "docker logs user-tray-user-tray-1 -f" Enter
# appliance-tray
byobu new-window -t os:1 -n "app-tray"
byobu send-keys -t os:1 "cd appliance-tray" Enter
byobu send-keys -t os:1 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:1 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:1 "docker logs appliance-tray-appliance-tray-1 -f" Enter
# security-tray
byobu new-window -t os:2 -n "sec-tray"
byobu send-keys -t os:2 "cd security-tray" Enter
byobu send-keys -t os:2 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:2 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:2 "docker logs security-tray-security-tray-1 -f" Enter
# proof-engine
byobu new-window -t os:3 -n "proof"
byobu send-keys -t os:3 "cd proof-engine" Enter
byobu send-keys -t os:3 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:3 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:3 "docker logs proof-engine-proof-engine-1 -f" Enter
# vault-oracle
byobu new-window -t os:4 -n "voracle"
byobu send-keys -t os:4 "cd vault-oracle" Enter
byobu send-keys -t os:4 "docker compose pull" Enter
byobu send-keys -t os:4 "docker compose up -d" Enter
byobu send-keys -t os:4 "docker logs vault-oracle -f" Enter
# genome-oracle
byobu new-window -t os:5 -n "oracle"
byobu send-keys -t os:5 "cd oracle" Enter
byobu send-keys -t os:5 "docker compose pull" Enter
byobu send-keys -t os:5 "docker compose up -d" Enter
byobu send-keys -t os:5 "docker logs genome-oracle -f" Enter
# convey
byobu new-window -t os:6 -n "convey"
byobu send-keys -t os:6 "cd convey" Enter
byobu send-keys -t os:6 "docker compose pull" Enter
byobu send-keys -t os:6 "docker compose up -d" Enter
byobu send-keys -t os:6 "docker logs convey-rabbitmq-1 -f" Enter
# logistics
byobu new-window -t os:7 -n "logstc"
byobu send-keys -t os:7 "cd logistics" Enter
byobu send-keys -t os:7 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:7 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:7 "docker logs logistics-logistics-1 -f" Enter
# onli-cloud-tray
byobu new-window -t os:8 -n "oct"
byobu send-keys -t os:8 "cd onli-cloud-tray" Enter
byobu send-keys -t os:8 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:8 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:8 "docker logs onli-cloud-tray-onli-cloud-tray-1 -f" Enter
# transfer-agent
byobu new-window -t os:9 -n "ta"
byobu send-keys -t os:9 "cd transfer-agent" Enter
byobu send-keys -t os:9 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:9 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:9 "docker logs transfer-agent-transfer-agent-1 -f" Enter
# treasury
byobu new-window -t os:10 -n "tr"
byobu send-keys -t os:10 "cd treasury" Enter
byobu send-keys -t os:10 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:10 "sleep 10" Enter # wait for oracle to start
byobu send-keys -t os:10 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:10 "docker logs treasury-treasury-1 -f" Enter
# bill-breaker
byobu new-window -t os:11 -n "bb"
byobu send-keys -t os:11 "cd bill-breaker" Enter
byobu send-keys -t os:11 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:11 "sleep 60" Enter # wait for treasury to start
byobu send-keys -t os:11 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:11 "docker logs bill-breaker-bill-breaker-1 -f" Enter
# cloud-vault-tray
byobu new-window -t os:12 -n "cvt"
byobu send-keys -t os:12 "cd cloud-vault-tray" Enter
byobu send-keys -t os:12 "docker compose -f docker-compose-multi-server.yml pull" Enter
byobu send-keys -t os:12 "docker compose -f docker-compose-multi-server.yml up -d" Enter
byobu send-keys -t os:12 "docker logs cloud-vault-tray-cloud-vault-tray-1 -f" Enter
byobu attach-session -t os