-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_node.sh
215 lines (156 loc) · 6.8 KB
/
install_node.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
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
##Install Script for plugin nodes via Docker.
echo -e "\n\n## Plugin Docker Install -- https://goplugin.co -- made by nmzn (Twitter @itsnmzn) 01/2022\n"
echo -e "\n\n## Please make sure to read the readme.md after installing!!!"
echo -e "## Version 0.2 \n\n"
echo
echo -e "\n\n################# Updating System #################\n\n"
cd
sudo apt update && sudo apt upgrade -y
echo -e "\n\n################# Changing Directory #################\n\n"
sudo mkdir -p /opt/docker/goplugin
cd /opt/docker/goplugin
echo -e "\n\n################# getting git repositories #################\n\n"
sudo git clone -b docker_branch_v1 https://github.com/GoPlugin/plugin-deployment.git && cd plugin-deployment/
sudo git clone https://github.com/nmzn/pluginnode-docker.git && cd pluginnode-docker && sudo cp docker-compose.yaml /opt/docker/goplugin/plugin-deployment && cd ..
echo -e "\n\n################# installing latest docker compose #################\n\n"
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo -e "\n\n################# Changing Credentials #################\n\n"
echo
#### Node Login Credentials ###
echo -e "Please type an Email adress to login to your node. Doesnt need to be related to the plugin login."
echo
until [[ "$mail" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]
do
echo
read -p "Enter a valid Mail adress: " mail
done
echo
echo "Mail adress is valid."
echo
echo
while true; do
echo "Please type a Password for your node login. (At least 7 characters with 2 upper case characters, 2 lower case characters, 2 digits and 1 special character."
echo
read -s -p "Enter Password: " nodepw
echo
echo
FAIL=no
# 7 characters
[[ ${#nodepw} -ge 7 ]] || FAIL=yes
# 2 upper case letters
echo $nodepw | grep -q "[A-Z].*[A-Z]" || FAIL=yes
# 2 lower case letters
echo $nodepw | grep -q "[a-z].*[a-z]" || FAIL=yes
# 2 digits
echo $nodepw | grep -q "[0-9].*[0-9]" || FAIL=yes
# 1 non-alphanumeric character (no spaces)
echo $nodepw | grep -q "[^a-zA-Z0-9]" || FAIL=yes
[[ ${FAIL} == "no" ]] && break
echo "Password invalid"
echo
done
echo "Node Password is valid"
echo
### Postgres Password ###
echo
while true; do
echo "Please type a Password for your Postgres Database. At least 4 characters with 1 Upper case, 1 lower case character and 1 digit. No Special Characters!"
echo
read -s -p "Enter Password: " pgrspw
echo
echo
FAIL=no
# 4 characters
[[ ${#pgrspw} -ge 4 ]] || FAIL=yes
# 1 upper case letters
echo $pgrspw | grep -q "[A-Z]" || FAIL=yes
# 1 lower case letters
echo $pgrspw | grep -q "[a-z]" || FAIL=yes
# 1 digits
echo $pgrspw | grep -q "[0-9]" || FAIL=yes
[[ ${FAIL} == "no" ]] && break
echo "Postgres Password invalid"
echo
done
echo "Postgres Password is valid"
echo
### Keystore Password ###
echo
while true; do
echo "Please type your Keystore Password."
echo "Password must be LONGER than 12 characters contain at least 3 upper case characters, 3 lower case characters, 3 numbers and 3 special characters (no spaces)"
echo
read -s -p "Enter Password: " kstpw
echo
echo
FAIL=no
# 12 characters
[[ ${#kstpw} -ge 13 ]] || FAIL=yes
# 3 upper case letters
echo $kstpw | grep -q "[A-Z].*[A-Z].*[A-Z]" || FAIL=yes
# 3 lower case letters
echo $kstpw | grep -q "[a-z].*[a-z].*[a-z]" || FAIL=yes
# 3 digits
echo $kstpw | grep -q "[0-9].*[0-9].*[0-9]" || FAIL=yes
# 3 non-alphanumeric character (no spaces)
echo $kstpw | grep -q "[^a-zA-Z0-9].*[^a-zA-Z0-9].*[^a-zA-Z0-9]" || FAIL=yes
[[ ${FAIL} == "no" ]] && break
echo "Password invalid"
echo
done
echo "Keystore Password is valid"
echo
echo -e "\nSetting Postgres Password"
sudo sed -i "s/plugin1234/$pgrspw/g" plugin.env ei.env
sudo sed -i "s/plugin1234/$pgrspw/g" docker-compose.yaml
sudo sed -i "s/\postgres\b/dbuser/g" plugin.env
sudo sed -i "s/\postgres\b/dbuser/g" ei.env
sudo sed -i "s|"172.17.0.1"|psql_node|g" plugin.env
sudo sed -i "s|"172.17.0.1"|psql_ei|g" ei.env
echo
echo -e "Done..."
echo -e "\nSetting api Credentials"
sudo sed -i d .env.apicred
sudo sh -c 'echo "[email protected]" > .env.apicred'
sudo sh -c 'echo "mailpw" >> .env.apicred'
sudo sed -i "s/mail\@mail.com/$mail/g" .env.apicred
sudo sed -i "s/mailpw/$nodepw/g" .env.apicred
echo
echo -e "Done..."
echo -e "\nSetting Keystore Password"
sudo sed -i d .env.password
sudo sh -c 'echo "keystore" > .env.password'
sudo sed -i "s/keystore/$kstpw/g" .env.password
echo
echo -e "Done..."
echo -e "\n\n################# Bringing up node & database #################\n\n"
sudo docker-compose up -d
echo -e "\n\n################# Starting Node #################\n\n"
sudo docker exec -it plinode /bin/bash -c ". ~/.profile && pm2 start /pluginAdm/startNode.sh"
echo
echo -e "Waiting for Node to come up... (10 Seconds)"
sleep 10
echo
echo -e "\n\n################# Installing External Initiators #################\n\n"
sudo docker exec -it plinode /bin/bash -c ". ~/.profile && plugin admin login -f /pluginAdm/.env.apicred"
JOBKEYS=$(sudo docker exec -it plinode /bin/bash -c ". ~/.profile && plugin initiators create pluginei http://localhost:8080/jobs" | grep pluginei)
sudo sh -c "echo $JOBKEYS > eivar.env"
ICACCESSKEY=$(echo $JOBKEYS | sed 's/\ //g' | awk -F"║" '{print $4};')
ICSECRET=$(echo $JOBKEYS | sed 's/\ //g' | awk -F"║" '{print $5};')
CIACCESSKEY=$(echo $JOBKEYS | sed 's/\ //g' | awk -F"║" '{print $6};')
CISECRET=$(echo $JOBKEYS | sed 's/\ //g' | awk -F"║" '{print $7};')
sudo sed -i "s|"cc763c8ca9fe48508883f6d39f818ccf"|$ICACCESSKEY|g" ei.env
sudo sed -i "s|"jEG8wzejfexfjAeZWBy8SzS7XV+SfV22j0eq7CEnyc6SSsd35PtQlESP2RhYs1am"|$ICSECRET|g" ei.env
sudo sed -i "s|"pKgKE+XNYbU2FRX207LObetsCx56bGPXenU3XpUelAdRb73bXBE22tSLjPviRUav"|$CIACCESSKEY|g" ei.env
sudo sed -i "s|"FXllNVlkD8ADVjFr46teIGRaeWEZXsYVQRMdfmu+UmRV4aysZ30E/OkNadysLZsA"|$CISECRET|g" ei.env
sudo docker exec --env-file ei.env -it plinode /bin/bash -c ". ~/.profile && pm2 start /pluginAdm/startEI.sh"
echo -e "\n\n################# Creating service for automatic startup after reboot #################\n\n"
cp /root/plugin-deployment/oneClickDeploy/nodeboot.sh /usr/local/sbin/
chmod +x /usr/local/sbin/nodeboot.sh
cp /root/plugin-deployment/oneClickDeploy/nodeboot.service /etc/systemd/system/nodeboot.service
chmod +x /etc/systemd/system/nodeboot.service
systemctl enable nodeboot.service
systemctl daemon-reload
echo -e "\n\n################# Done #################\n\n"
echo -e "\n\n################# Node Setup completed. Oracle Deployment Part has to be done manually. Please see: https://docs.goplugin.co for further information #################\n\n"