forked from CommerciumBlockchain/masternode-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
558 lines (529 loc) · 16.4 KB
/
install.sh
File metadata and controls
558 lines (529 loc) · 16.4 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
#!/bin/bash
#####################################################################################
# Automatic installation for Commercium nodes #
#####################################################################################
RED='\033[0;97;41m'
STD='\033[0;0;39m'
GREEN='\e[1;97;42m'
BLUE='\e[1;97;44m'
pause(){
read -p "Press [Enter] key to continue - Press [CRTL+C] key to Exit..." fackEnterKey
}
show_menus() {
clear
echo ""
echo -e "\e[1;97;44m C O M M E R C I U M N O D E S A U T O I N S T A L L ${STD}"
echo ""
echo "1. Install Node"
echo "2. Install Masternode"
echo "3. Exit"
echo ""
echo -e "\e[1;97;41m ${STD}"
echo -e "\e[1;97;41m CAUTION!!: ${STD}"
echo -e "\e[1;97;41m For a successful setup, please clear your vps from any ${STD}"
echo -e "\e[1;97;41m previous Commercium core installation ${STD}"
echo -e "\e[1;97;41m ${STD}"
echo ""
}
Config_Full_Node(){
nodeIpAddress=`curl ifconfig.me/ip`
if [[ ${nodeIpAddress} =~ ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$ ]]; then
external_ip_line="externalip=${nodeIpAddress}"
else
external_ip_line="#externalip=external_IP_goes_here"
fi
rpcUserName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
rpcPassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
config="#----
rpcuser=$rpcUserName
rpcpassword=$rpcPassword
rpcallowip=127.0.0.1
#----
listen=1
server=1
daemon=1
maxconnections=64
#----
$external_ip_line
#----
txindex=1
addressindex=1
timestampindex=1
spentindex=1
addnode=seed01.commercium.net
addnode=seed02.commercium.net
addnode=seed03.commercium.net
addnode=seed04.commercium.net
addnode=explorer.commercium.net"
}
Config_Full_Node_Multi(){
rpcUserName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
rpcPassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
config="#----
\nrpcuser=\"'$rpcUserName'\"
\nrpcpassword=\"'$rpcPassword'\"
\nrpcallowip=127.0.0.1
\n#----
\nlisten=1
\nserver=1
\ndaemon=1
\nmaxconnections=64
\n#----
\nexternalip=\"'$i'\"
\n#----
\ntxindex=1
\naddressindex=1
\ntimestampindex=1
\nspentindex=1
\naddnode=seed01.commercium.net
\naddnode=seed02.commercium.net
\naddnode=seed03.commercium.net
\naddnode=seed04.commercium.net
\naddnode=explorer.commercium.net"
}
Config_Masternode(){
nodeIpAddress=`curl ifconfig.me/ip`
if [[ ${nodeIpAddress} =~ ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$ ]]; then
external_ip_line="externalip=${nodeIpAddress}"
else
external_ip_line="#externalip=external_IP_goes_here"
fi
rpcUserName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
rpcPassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
config="#----
rpcuser=$rpcUserName
rpcpassword=$rpcPassword
rpcallowip=127.0.0.1
#----
listen=1
server=1
daemon=1
maxconnections=64
#----
txindex=1
masternode=1
masternodeprivkey=$pv
$external_ip_line
#----
addnode=seed01.commercium.net
addnode=seed02.commercium.net
addnode=seed03.commercium.net
addnode=seed04.commercium.net
addnode=explorer.commercium.net"
}
Config_Masternode_Multi(){
nodeIpAddress=`curl ifconfig.me/ip`
if [[ ${nodeIpAddress} =~ ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$ ]]; then
external_ip_line="externalip=${nodeIpAddress}"
else
external_ip_line="#externalip=external_IP_goes_here"
fi
rpcUserName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
rpcPassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
config="#----
\nrpcuser=\"'$rpcUserName'\"
\nrpcpassword=\"'$rpcPassword'\"
\nrpcallowip=127.0.0.1
\n#----
\nlisten=1
\nserver=1
\ndaemon=1
\nmaxconnections=64
\n#----
\ntxindex=1
\nmasternode=1
\nmasternodeprivkey=\"'$pv'\"
\nexternalip=\"'$i'\"
\n#----
\naddnode=seed01.commercium.net
\naddnode=seed02.commercium.net
\naddnode=seed03.commercium.net
\naddnode=seed04.commercium.net
\naddnode=explorer.commercium.net"
}
install_Commercium_core(){
echo ""
echo -e "${GREEN} Start Installation Commercium core ${STD}"
sleep 1
h=$(( RANDOM % 23 + 1 ));
echo ""
echo -e "${GREEN} Install packages..... ${STD}"
yes | apt-get update
yes | apt-get install ufw python virtualenv git unzip pv nano htop libwww-perl
echo ""
echo -e "${GREEN} Firewall/Swapfile setup..... ${STD}"
sudo ufw allow ssh/tcp
sudo ufw limit ssh/tcp
sudo ufw allow 2019/tcp
sudo ufw logging on
yes | sudo ufw enable
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
sleep 2
echo ""
echo -e "${GREEN} Building Commercium core from source..... ${STD}"
rm -rf /usr/local/bin/Masternode
cd ~
latestrelease=$(curl --silent https://api.github.com/repos/CommerciumBlockchain/CommerciumContinuum/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
link="https://github.com/CommerciumBlockchain/CommerciumContinuum/archive/$latestrelease.tar.gz"
wget $link
tar -xvzf $latestrelease.tar.gz
file=${latestrelease//[v]/CommerciumContinuum-}
yes | sudo apt-get update
export LC_ALL=en_US.UTF-8
yes | sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl
yes | sudo apt-get install libgomp1
yes | sudo apt-get update
sleep 2
echo ""
echo -e "${GREEN} Compile Commercium core ..... ${STD}"
cd $file
./zcutil/fetch-params.sh
echo -e "${GREEN} Compile ${STD}"
echo ""
./zcutil/build.sh
cd ~
cp $file/src/commerciumd /usr/local/bin
cp $file/src/commercium-cli /usr/local/bin
cp $file/src/commercium-tx /usr/local/bin
cp $file/src/commercium-gtest /usr/local/bin
echo ""
echo -e "${GREEN} Configure Commercium core ..... ${STD}"
cd ~
mkdir ./.commercium
echo "$config" > ./.commercium/commercium.conf
cd ~
cd /usr/local/bin
mkdir Masternode
cd Masternode
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/Check-scripts.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/Update-scripts.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/UpdateNode.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/clearlog.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/daemon_check.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/Version
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/Masternode/blockcount
chmod 755 daemon_check.sh
chmod 755 UpdateNode.sh
chmod 755 Check-scripts.sh
chmod 755 Update-scripts.sh
chmod 755 clearlog.sh
cd ~
crontab -r
line="@reboot /usr/local/bin/commerciumd
0 0 * * * /usr/local/bin/Masternode/Check-scripts.sh
*/10 * * * * /usr/local/bin/Masternode/daemon_check.sh
0 $h * * * /usr/local/bin/Masternode/UpdateNode.sh
* * */2 * * /usr/local/bin/Masternode/clearlog.sh"
echo "$line" | crontab -u root -
echo -e "${GREEN} Commercium core Configured successfully ..... ${STD}"
echo ""
cd ~
rm $latestrelease.tar.gz
rm -rf \$file
echo -e "${GREEN} Rebooting ..... ${STD}"
reboot
}
install_Commercium_core_Multi(){
echo ""
echo -e "${GREEN} Connexion Vps ip $i ${STD}"
echo ""
sshpass -p $rootpass ssh -p$sshport -o StrictHostKeyChecking=no root@$i '
STD="\033[0;0;39m"
BLUE="\e[1;97;44m"
echo "#!/bin/bash
HOME=/root
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/root
h=\$(( RANDOM % 23 + 1 ));
configdata=\"'$config'\"
rm -rf /usr/local/bin/Masternode
yes | apt-get update
yes | apt-get install ufw python virtualenv git unzip pv nano htop libwww-perl
sudo ufw allow ssh/tcp
sudo ufw limit ssh/tcp
sudo ufw allow 2019/tcp
sudo ufw logging on
yes | sudo ufw enable
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo \"/swapfile none swap sw 0 0\" >> /etc/fstab
sleep 4
cd ~
yes | sudo apt-get update
export LC_ALL=en_US.UTF-8
yes | sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl
yes | sudo apt-get install libgomp1
yes | sudo apt-get update
sleep 2
latestrelease=\$(curl --silent https://api.github.com/repos/CommerciumBlockchain/CommerciumContinuum/releases/latest | grep '"'"\\$"\"tag_name"\\$"\":'"' | sed -E '"'s/.*"\\$"\"([^"\\$"\"]+)"\\$"\".*/\1/'"')
link=\"https://github.com/CommerciumBlockchain/CommerciumContinuum/archive/$latestrelease.tar.gz\"
wget \$link
tar -xvzf \$latestrelease.tar.gz
file=\${latestrelease//[v]/CommerciumContinuum-}
cd \$file
./zcutil/fetch-params.sh
./zcutil/build.sh
cd ~
cp $file/src/commerciumd /usr/local/bin
cp $file/src/commercium-cli /usr/local/bin
cp $file/src/commercium-tx /usr/local/bin
cp $file/src/commercium-gtest /usr/local/bin
cd ~
mkdir ./.commercium
echo -e \"\$configdata\" > ./.commercium/commercium.conf
cd ~
cd /usr/local/bin
mkdir Masternode
cd Masternode
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/Check-scripts.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/Update-scripts.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/UpdateNode.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/clearlog.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/daemon_check.sh
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/Version
wget https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/Masternode/blockcount
chmod 755 daemon_check.sh
chmod 755 UpdateNode.sh
chmod 755 Check-scripts.sh
chmod 755 Update-scripts.sh
chmod 755 clearlog.sh
cd ~
crontab -r
line=\"@reboot /usr/local/bin/commerciumd
0 0 * * * /usr/local/bin/Masternode/Check-scripts.sh
*/10 * * * * /usr/local/bin/Masternode/daemon_check.sh
0 \$h * * * /usr/local/bin/Masternode/UpdateNode.sh
* * */2 * * /usr/local/bin/Masternode/clearlog.sh\"
echo \"\$line\" | crontab -u root -
cd ~
rm \$latestrelease.tar.gz
rm -rf \$file
reboot" > /root/install.sh
chmod 755 install.sh
install="@reboot /root/install.sh"
echo "$install" | crontab -u root -
echo ""
echo -e "${BLUE} ${STD}"
echo -e "${BLUE} Script Installation launched on Vps,be patient few minutes and will be ready to use. ${STD}"
echo -e "${BLUE} ${STD}"
echo ""
reboot'
}
read_options(){
local choice
read -p "Enter choice [ 1 - 3] " choice
case $choice in
#### Commercium Node installation
1)type="Node"
echo ""
echo -e "${BLUE} Start Install Commercium ${type} ${STD}"
echo ""
echo "Do you want to start the Commercium ${type} installation?"
pause
echo ""
echo -e "${GREEN} Single (Local vps) - Multi (Multi vps's) ${STD}"
PS3='Please enter your choice: '
options=("Install Single ${type}" "Install Multi ${type}")
select opt in "${options[@]}"
do
case $opt in
"Install Single ${type}")
break
;;
"Install Multi ${type}")
break
;;
*) echo invalid option;;
esac
done
#### Commercium Single Node installation
if [ "$opt" == "Install Single ${type}" ]; then
Config_Full_Node
install_Commercium_core
else
#### 3Dcoin Multi Nodes installation
echo ""
echo ""
read -p "Same SSH Port and Password for all vps's? (Y/N)" -n 1 -r
echo "" # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo -e "${GREEN} Enter Vps ip's ${STD}"
echo ""
sleep 2
echo -e "Please enter your vps ip's: ${RED}(Exemple: 111.111.111.111-222.222.222.222-... ) ${STD}"
unset ip
while [ -z ${ip} ]; do
read -p "IP HERE: " ip
done
unset sshport
while [ -z ${sshport} ]; do
read -p "SSH Port: " sshport
done
unset rootpass
while [ -z ${rootpass} ]; do
read -s -p "Password: " rootpass
done
echo ""
vpsip=$(echo $ip | tr "-" " ")
apt-get update
yes | apt-get install sshpass
for i in $vpsip
do
Config_Full_Node_Multi
install_Commercium_core_Multi
done
elif [[ $REPLY =~ ^[Nn]$ ]]; then
sleep 2
echo -e "Please enter your vps's data: 'Host:Password:SSHPort' ${RED}( Exemple: 111.111.111.111:ERdX5h64dSer:22-222.222.222.222:Wz65D232Fty:165-... )${STD}"
unset ip
while [ -z ${ip} ]; do
read -p "DATA HERE: " ip
done
apt-get update
yes | apt-get install sshpass
data=$(echo $ip | tr "-" " ")
for ipdata in $data
do
vpsdata=$(echo $ipdata | tr ":" "\n")
declare -a array=($vpsdata)
i=${array[0]}
rootpass=${array[1]}
sshport=${array[2]}
if [ -z "$rootpass" ] || [ -z "$sshport" ] || [ -z "$i" ]
then
echo -e "Please enter a correct vps's data ${RED}( Exemple: 111.111.111.111:ERdX5h64dSer:22 222.222.222.222:Wz65D232Fty:165 ... )${STD}"
else
Config_Full_Node_Multi
install_Commercium_core_Multi
fi
done
else
exit;
fi
fi
exit 0;;
#### Commercium Masternode installation
2) type="Masternode"
echo ""
echo -e "${BLUE} Start Install Commercium ${type} ${STD}"
echo ""
echo "Do you want to start the Commercium ${type} installation?"
pause
echo ""
echo -e "${GREEN} Single (Local vps) - Multi (Multi vps's) ${STD}"
PS3='Please enter your choice: '
options=("Install Single ${type}" "Install Multi ${type}")
select opt in "${options[@]}"
do
case $opt in
"Install Single ${type}")
break
;;
"Install Multi ${type}")
break
;;
*) echo invalid option;;
esac
done
#### Commercium Single Masternode installation
if [ "$opt" == "Install Single ${type}" ]; then
unset pv
while [ -z ${pv} ]; do
read -p "Please Enter Masternode Private key: " pv
done
Config_Masternode
install_Commercium_core
else
#### Commercium Multi Masternodes installation
echo ""
echo ""
read -p "Same SSH Port and Password for all vps's? (Y/N)" -n 1 -r
echo "" # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo -e "${GREEN} Enter Vps ip's ${STD}"
echo ""
sleep 2
echo -e "Please enter your vps ip's: ${RED}(Exemple: 111.111.111.111-222.222.222.222-... ) ${STD}"
unset ip
while [ -z ${ip} ]; do
read -p "IP HERE: " ip
done
unset sshport
while [ -z ${sshport} ]; do
read -p "SSH Port: " sshport
done
unset rootpass
while [ -z ${rootpass} ]; do
read -s -p "Password: " rootpass
done
echo ""
vpsip=$(echo $ip | tr "-" " ")
apt-get update
yes | apt-get install sshpass
for i in $vpsip
do
echo ""
echo -e "${GREEN} Masternode Private key ${STD}"
unset pv
while [ -z ${pv} ]; do
read -p "Please Enter Masternode Private key: " pv
done
Config_Masternode_Multi
install_Commercium_core_Multi
done
elif [[ $REPLY =~ ^[Nn]$ ]]; then
sleep 2
echo -e "Please enter your vps's data: 'Host:Password:SSHPort' ${RED}( Exemple: 111.111.111.111:ERdX5h64dSer:22-222.222.222.222:Wz65D232Fty:165-... )${STD}"
unset ip
while [ -z ${ip} ]; do
read -p "DATA HERE: " ip
done
apt-get update
yes | apt-get install sshpass
data=$(echo $ip | tr "-" " ")
for ipdata in $data
do
vpsdata=$(echo $ipdata | tr ":" "\n")
declare -a array=($vpsdata)
i=${array[0]}
rootpass=${array[1]}
sshport=${array[2]}
if [ -z "$rootpass" ] || [ -z "$sshport" ] || [ -z "$i" ]
then
echo -e "Please enter a correct vps's data ${RED}( Exemple: 111.111.111.111:ERdX5h64dSer:22 222.222.222.222:Wz65D232Fty:165 ... )${STD}"
else
echo ""
echo -e "${GREEN} Masternode Private key ${STD}"
unset pv
while [ -z ${pv} ]; do
read -p "Please Enter Masternode Private key: " pv
done
Config_Masternode_Multi
install_Commercium_core_Multi
fi
done
else
exit;
fi
fi
exit 0;;
3) exit 0;;
*) echo -e "${RED}Invalid option...${STD}" && sleep 2
esac
}
while true
do
show_menus
read_options
done