-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy patheosbpinit.sh
More file actions
executable file
·219 lines (191 loc) · 4.88 KB
/
eosbpinit.sh
File metadata and controls
executable file
·219 lines (191 loc) · 4.88 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/bash
EOS_TAG=""
INSTALL_APPS=(
"tmux"
"axel"
"git"
"apt-transport-https"
"ca-certificates"
"curl"
"python-pip"
"tree"
"supervisor"
"wireguard"
"certbot"
"python-setuptools"
"python-dev"
"libssl-dev"
"hexcurse"
"ntpstat"
)
PIP_APPS=(
"requests"
"docker-compose"
"libconf"
"argparse"
"pyjsonrpc"
"stormssh"
)
APP_REPO=(
"ppa:git-core/ppa"
"ppa:wireguard/wireguard"
"ppa:certbot/certbot"
"ppa:deadsnakes/ppa"
#"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
)
GPG_KEYS=(
#"https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg"
)
INIT_PATH="${HOME}/inithost"
mkdir -p $INIT_PATH
cd $INIT_PATH
if [[ $? -ne 0 ]]; then
echo "FAILED to cd $INIT_PATH"
exit 1
fi
if [[ $1 != "init" && $1 != "source" && $1 != "docker" && $1 != "pull" ]]; then
echo "Usage: $0 init|pull|source|docker"
echo " init: just initialize the machine"
echo " pull: just pull the latest code for EOSIO"
echo " source: just pull the latest code for EOSIO and call eosio_build.sh"
echo " docker: just pull the latest code for EOSIO and wait for docker build"
exit 1
fi
function install_docker() {
echo ">>>>>>>>>>> install Docker"
sudo mkdir -p /etc/docker/
sudo wget https://raw.githubusercontent.com/EOSBIXIN/eostoolkit/master/docker-etc-daemon.json -O /etc/docker/daemon.json
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER
}
function init_pip() {
echo ">>>>>>>>>>> install PIP apps"
sudo pip install --upgrade pip
for item in "${PIP_APPS[@]}"; do
sudo pip install "$item" --upgrade
done
}
function pull_eostoolkit() {
cd $INIT_PATH
if [[ ! -e eostoolkit ]]; then
git clone https://github.com/winlin/eostoolkit.git
if [[ $? -ne 0 ]]; then
echo "FAILED to get eostoolkit code"
exit 1
fi
fi
cd eostoolkit
git pull origin
}
function init_host() {
sudo mkdir -p /data
sudo chown $USER:$USER /data
sudo apt-get update
echo ">>>>>>>>>>> install GPG Keys"
for item in "${GPG_KEYS[@]}"; do
curl -fsSL "$item" | sudo apt-key add -
done
sudo apt-get install -y software-properties-common
echo ">>>>>>>>>>> install repositories"
for item in "${APP_REPO[@]}"; do
sudo apt-add-repository "$item"
done
sudo apt-get update
echo ">>>>>>>>>>> install apps"
for item in "${INSTALL_APPS[@]}"; do
sudo apt-get install -y "$item"
if [[ $? -ne 0 ]]; then
echo "FAILED to install $item"
exit 1
fi
done
# initialize bashrc
alias | grep dlog
if [[ $? != 0 ]]; then
echo "alias dlog='sudo docker-compose logs -t -f'" >> ~/.bashrc
fi
wget https://raw.githubusercontent.com/EOSBIXIN/eostoolkit/master/tmux.conf -O ~/.tmux.conf
install_docker
init_pip
pull_eostoolkit
}
function pull_eossrc() {
mkdir -p ~/opt/
cd ~/opt/
if [[ ! -e eos ]]; then
git clone https://github.com/EOSIO/eos --recursive
if [[ $? -ne 0 ]]; then
echo "FAILED to get eos code"
exit 1
fi
fi
cd eos
git checkout scripts/eosio_build_ubuntu.sh
git checkout master --recurse-submodules
git pull origin --recurse-submodules
git submodule update --init --recursive
}
function build_eossrc() {
pull_eossrc
cd ~/opt/eos/
git checkout tags/$EOS_TAG -b $EOS_TAG --recurse-submodules
if [[ $? -ne 0 ]]; then
echo "FAILED to get checkout tag $EOS_TAG"
exit 1
fi
git submodule update --init --recursive
./eosio_build.sh
if [[ $? -ne 0 ]]; then
echo "FAILED to build EOS with tag $EOS_TAG"
exit 1
fi
cd build
make test
if [[ $? -ne 0 ]]; then
echo "FAILED to make test EOS with tag $EOS_TAG"
exit 1
fi
sudo make install
}
function build_eosdocker() {
pull_eossrc
cd ~/opt/eos/
git branch -d $EOS_TAG
git checkout tags/$EOS_TAG -b $EOS_TAG --recurse-submodules
if [[ $? -ne 0 ]]; then
echo "FAILED to get checkout tag $EOS_TAG"
exit 1
fi
git submodule update --init --recursive
if [[ $? -ne 0 ]]; then
echo "FAILED to fetch latest code with tag $EOS_TAG"
exit 1
fi
}
if [[ $1 == "init" ]]; then
init_host
exit 0
fi
if [[ $1 == "pull" ]]; then
pull_eossrc
exit 0
fi
echo "update eostoolkit ..."
pull_eostoolkit
EOS_TAG=$2
if [[ $EOS_TAG == "" ]]; then
echo "Please supply the target tag name"
exit 1
fi
echo "Going to checkout tag: ${EOS_TAG}"
if [[ $1 == "source" ]]; then
build_eossrc
exit 0
fi
if [[ $1 == "docker" ]]; then
build_eosdocker
exit 0
fi