forked from zSAM-Project/masternode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vivaldi3mn_1vps.sh
270 lines (240 loc) · 9.24 KB
/
vivaldi3mn_1vps.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
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
#/bin/bash
################################################################################
# Author: Phongthep K
# Date: July, 29th 2018
#
# Program:
#
# Install VIVALDI Coin masternode on clean VPS with Ubuntu 16.04
# Need 3 IP on VPS
################################################################################
echo && echo
echo "****************************************************************************"
echo "* *"
echo "* This script will install and configure your VIVALDI Coin masternode. *"
echo "* *"
echo "****************************************************************************"
echo && echo
#set -o errexit
cd ~
sudo locale-gen en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
sudo apt-get install bc git nano rpl wget python-virtualenv -qq -y > /dev/null 2>&1
sudo apt-get install build-essential libtool automake autoconf -qq -y > /dev/null 2>&1
sudo apt-get install autotools-dev autoconf pkg-config libssl-dev -qq -y > /dev/null 2>&1
sudo apt-get install libgmp3-dev libevent-dev bsdmainutils libboost-all-dev -qq -y > /dev/null 2>&1
sudo apt-get install software-properties-common python-software-properties -qq -y > /dev/null 2>&1
sudo add-apt-repository ppa:bitcoin/bitcoin -y > /dev/null 2>&1
sudo apt-get update -qq -y > /dev/null 2>&1
sudo apt-get upgrade -qq -y > /dev/null 2>&1
sudo apt-get install libdb4.8-dev libdb4.8++-dev -qq -y > /dev/null 2>&1
sudo apt-get install libminiupnpc-dev -qq -y > /dev/null 2>&1
sudo apt-get install libzmq5 -qq -y > /dev/null 2>&1
sudo apt-get install virtualenv -qq -y > /dev/null 2>&1
sudo apt-get update -qq -y > /dev/null 2>&1
sudo apt-get upgrade -qq -y > /dev/null 2>&1
sudo apt-get install unzip -y
COINDOWNLOADLINK1=https://github.com/VivaldiCoin/Vivaldi/releases/download/v1.1.1.1/vivaldid
COINDOWNLOADLINK2=https://github.com/VivaldiCoin/Vivaldi/releases/download/v1.1.1.1/vivaldi-cli
VIVALDI_RPC_PASS=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 ; echo ""`
VIVALDI_RPC_PORT1=27329
VIVALDI_RPC_PORT2=27339
VIVALDI_RPC_PORT3=27349
echo "Type the IP #1 of this server, followed by [ENTER]:"
read IP1
echo ""
echo "Type the IP #2 of this server, followed by [ENTER]:"
read IP2
echo ""
echo "Type the IP #3 of this server, followed by [ENTER]:"
read IP3
echo ""
echo "Enter Masternode Account Login Password"
read VIVALDI_USER_PASS
sudo userdel vivaldimn1
sudo useradd -U -m vivaldimn1 -s /bin/bash
echo "vivaldimn1:${VIVALDI_USER_PASS}" | sudo chpasswd
sudo userdel vivaldimn2
sudo useradd -U -m vivaldimn2 -s /bin/bash
echo "vivaldimn2:${VIVALDI_USER_PASS}" | sudo chpasswd
sudo userdel vivaldimn3
sudo useradd -U -m vivaldimn3 -s /bin/bash
echo "vivaldimn3:${VIVALDI_USER_PASS}" | sudo chpasswd
sudo wget $COINDOWNLOADLINK1 --directory-prefix /root/
sudo wget $COINDOWNLOADLINK2 --directory-prefix /root/
echo "Copy VIVALDI files to MN1!"
sudo cp /root/vivaldi* /home/vivaldimn1
sudo chown -R vivaldimn1:vivaldimn1 /home/vivaldimn1/vivaldi*
sudo chmod 755 /home/vivaldimn1/vivaldi*
echo "Copy VIVALDI files to MN2!"
sudo cp /root/vivaldi* /home/vivaldimn2
sudo chown -R vivaldimn2:vivaldimn2 /home/vivaldimn2/vivaldi*
sudo chmod 755 /home/vivaldimn2/vivaldi*
echo "Copy VIVALDI files to MN3!"
sudo cp /root/vivaldi* /home/vivaldimn3
sudo chown -R vivaldimn3:vivaldimn3 /home/vivaldimn3/vivaldi*
sudo chmod 755 /home/vivaldimn3/vivaldi*
sudo rm -rf /root/vivaldi*
sudo rm -rf /home/vivaldimn1/.vivaldi/
CONF_DIR=/home/vivaldimn1/.vivaldi/
CONF_FILE=vivaldi.conf
mkdir -p $CONF_DIR
echo "rpcuser=vivaldicoinrpc" >> $CONF_DIR/$CONF_FILE
echo "rpcpassword=${VIVALDI_RPC_PASS}" >> $CONF_DIR/$CONF_FILE
echo "rpcallowip=127.0.0.1" >> $CONF_DIR/$CONF_FILE
echo "rpcport=${VIVALDI_RPC_PORT1}" >> $CONF_DIR/$CONF_FILE
echo "port=22733" >> $CONF_DIR/$CONF_FILE
echo "listen=1" >> $CONF_DIR/$CONF_FILE
echo "server=1" >> $CONF_DIR/$CONF_FILE
echo "daemon=1" >> $CONF_DIR/$CONF_FILE
echo "maxconnections=256" >> $CONF_DIR/$CONF_FILE
echo "bind=${IP1}:22733" >> $CONF_DIR/$CONF_FILE
sudo chown -R vivaldimn1:vivaldimn1 /home/vivaldimn1/.vivaldi/
sudo chown 500 /home/vivaldimn1/.vivaldi/vivaldi.conf
sudo rm -rf /home/vivaldimn2/.vivaldi/
CONF_DIR=/home/vivaldimn2/.vivaldi/
CONF_FILE=vivaldi.conf
mkdir -p $CONF_DIR
echo "rpcuser=vivaldicoinrpc" >> $CONF_DIR/$CONF_FILE
echo "rpcpassword=${VIVALDI_RPC_PASS}" >> $CONF_DIR/$CONF_FILE
echo "rpcallowip=127.0.0.1" >> $CONF_DIR/$CONF_FILE
echo "rpcport=${VIVALDI_RPC_PORT2}" >> $CONF_DIR/$CONF_FILE
echo "port=22733" >> $CONF_DIR/$CONF_FILE
echo "listen=1" >> $CONF_DIR/$CONF_FILE
echo "server=1" >> $CONF_DIR/$CONF_FILE
echo "daemon=1" >> $CONF_DIR/$CONF_FILE
echo "maxconnections=256" >> $CONF_DIR/$CONF_FILE
echo "bind=${IP2}:22733" >> $CONF_DIR/$CONF_FILE
sudo chown -R vivaldimn2:vivaldimn2 /home/vivaldimn2/.vivaldi/
sudo chown 500 /home/vivaldimn2/.vivaldi/vivaldi.conf
sudo rm -rf /home/vivaldimn3/.vivaldi/
CONF_DIR=/home/vivaldimn3/.vivaldi/
CONF_FILE=vivaldi.conf
mkdir -p $CONF_DIR
echo "rpcuser=vivaldicoinrpc" >> $CONF_DIR/$CONF_FILE
echo "rpcpassword=${VIVALDI_RPC_PASS}" >> $CONF_DIR/$CONF_FILE
echo "rpcallowip=127.0.0.1" >> $CONF_DIR/$CONF_FILE
echo "rpcport=${VIVALDI_RPC_PORT3}" >> $CONF_DIR/$CONF_FILE
echo "port=22733" >> $CONF_DIR/$CONF_FILE
echo "listen=1" >> $CONF_DIR/$CONF_FILE
echo "server=1" >> $CONF_DIR/$CONF_FILE
echo "daemon=1" >> $CONF_DIR/$CONF_FILE
echo "maxconnections=256" >> $CONF_DIR/$CONF_FILE
echo "bind=${IP3}:22733" >> $CONF_DIR/$CONF_FILE
sudo chown -R vivaldimn3:vivaldimn3 /home/vivaldimn3/.vivaldi/
sudo chown 500 /home/vivaldimn3/.vivaldi/vivaldi.conf
sudo tee /etc/systemd/system/vivaldimn1.service <<EOF
[Unit]
Description=VIVALDI Coin, distributed currency daemon
After=syslog.target network.target
[Service]
Type=forking
User=vivaldimn1
Group=vivaldimn1
WorkingDirectory=/home/vivaldimn1/
ExecStart=/home/vivaldimn1/vivaldid
ExecStop=/home/vivaldimn1/vivaldi-cli stop
Restart=on-failure
RestartSec=120
PrivateTmp=true
TimeoutStopSec=120
TimeoutStartSec=120
StartLimitInterval=120
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
EOF
sudo tee /etc/systemd/system/vivaldimn2.service <<EOF
[Unit]
Description=VIVALDI Coin, distributed currency daemon
After=syslog.target network.target
[Service]
Type=forking
User=vivaldimn2
Group=vivaldimn2
WorkingDirectory=/home/vivaldimn2/
ExecStart=/home/vivaldimn2/vivaldid
ExecStop=/home/vivaldimn2/vivaldi-cli stop
Restart=on-failure
RestartSec=120
PrivateTmp=true
TimeoutStopSec=120
TimeoutStartSec=120
StartLimitInterval=120
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
EOF
sudo tee /etc/systemd/system/vivaldimn3.service <<EOF
[Unit]
Description=VIVALDI Coin, distributed currency daemon
After=syslog.target network.target
[Service]
Type=forking
User=vivaldimn3
Group=vivaldimn3
WorkingDirectory=/home/vivaldimn3/
ExecStart=/home/vivaldimn3/vivaldid
ExecStop=/home/vivaldimn3/vivaldi-cli stop
Restart=on-failure
RestartSec=120
PrivateTmp=true
TimeoutStopSec=120
TimeoutStartSec=120
StartLimitInterval=120
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
EOF
sudo -H -u vivaldimn1 /home/vivaldimn1/vivaldid
echo "Booting VIVALDI MN1 and creating keypool"
sleep 10
MNGENKEY1=`sudo -H -u vivaldimn1 /home/vivaldimn1/vivaldi-cli masternode genkey`
echo -e "masternode=1\nmasternodeaddr=${IP1}:22733\nmasternodeprivkey=${MNGENKEY1}" | sudo tee -a /home/vivaldimn1/.vivaldi/vivaldi.conf
sudo -H -u vivaldimn1 /home/vivaldimn1/vivaldi-cli stop
sudo systemctl enable vivaldimn1
sudo systemctl start vivaldimn1
sudo -H -u vivaldimn2 /home/vivaldimn2/vivaldid
echo "Booting VIVALDI MN2 and creating keypool"
sleep 10
MNGENKEY2=`sudo -H -u vivaldimn2 /home/vivaldimn2/vivaldi-cli masternode genkey`
echo -e "masternode=1\nmasternodeaddr=${IP2}:22733\nmasternodeprivkey=${MNGENKEY2}" | sudo tee -a /home/vivaldimn2/.vivaldi/vivaldi.conf
sudo -H -u vivaldimn2 /home/vivaldimn2/vivaldi-cli stop
sudo systemctl enable vivaldimn2
sudo systemctl start vivaldimn2
sudo -H -u vivaldimn3 /home/vivaldimn3/vivaldid
echo "Booting VIVALDI MN3 and creating keypool"
sleep 10
MNGENKEY3=`sudo -H -u vivaldimn3 /home/vivaldimn3/vivaldi-cli masternode genkey`
echo -e "masternode=1\nmasternodeaddr=${IP3}:22733\nmasternodeprivkey=${MNGENKEY3}" | sudo tee -a /home/vivaldimn3/.vivaldi/vivaldi.conf
sudo -H -u vivaldimn3 /home/vivaldimn3/vivaldi-cli stop
sudo systemctl enable vivaldimn3
sudo systemctl start vivaldimn3
echo " "
echo " "
echo "==============================="
echo "VIVALDI Coin Masternode installed!"
echo "==============================="
echo "Copy and keep that information in secret:"
echo "masternodeaddr #1 key: ${MNGENKEY1}"
echo "masternodeaddr #2 key: ${MNGENKEY2}"
echo "masternodeaddr #3 key: ${MNGENKEY3}"
echo "SSH password for user \"vivaldimn1@${IP1},vivaldimn2@${IP2},vivaldimn3@${IP3}\": ${VIVALDI_USER_PASS}"
echo "Prepared masternode.conf string:"
echo "MN1 ${IP1}:22733 ${MNGENKEY1} INPUTTX INPUTINDEX"
echo "MN2 ${IP2}:22733 ${MNGENKEY2} INPUTTX INPUTINDEX"
echo "MN3 ${IP3}:22733 ${MNGENKEY3} INPUTTX INPUTINDEX"
sudo apt-get install -y ufw
sudo ufw allow ssh/tcp
sudo ufw limit ssh/tcp
sudo ufw allow 27329/tcp
sudo ufw allow 27339/tcp
sudo ufw allow 27349/tcp
sudo ufw allow 22733/tcp
sudo ufw logging on
sudo ufw --force enable
sudo ufw status
exit 0