-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinitubuntu.sh
More file actions
147 lines (123 loc) · 3.33 KB
/
initubuntu.sh
File metadata and controls
147 lines (123 loc) · 3.33 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
#!/bin/bash
EOS_TAG=""
INSTALL_APPS=(
"tmux"
"axel"
"git"
"apt-transport-https"
"ca-certificates"
"curl"
"tree"
"supervisor"
"python-setuptools"
"python-dev"
"libssl-dev"
"hexcurse"
"ntpstat"
"software-properties-common"
"python3.8"
"python3.8-distutils"
)
PIP_APPS=(
"requests"
"docker-compose"
"libconf"
"argparse"
"pyjsonrpc"
"stormssh"
"orjson"
"ujson"
"uvloop"
"tornado"
)
APP_REPO=(
"ppa:git-core/ppa"
"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 pip3.8 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
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3.8 get-pip.py
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
install_docker
init_pip
pull_eostoolkit
}
if [[ $1 == "init" ]]; then
init_host
exit 0
fi