forked from triskelpremium/TriskelPremium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
307 lines (258 loc) · 7.88 KB
/
install.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
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
#!/bin/bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-a|--advanced)
ADVANCED="y"
shift
;;
-n|--normal)
ADVANCED="n"
FAIL2BAN="y"
UFW="y"
BOOTSTRAP="y"
shift
;;
-i|--externalip)
EXTERNALIP="$2"
ARGUMENTIP="y"
shift
shift
;;
-k|--privatekey)
KEY="$2"
shift
shift
;;
-f|--fail2ban)
FAIL2BAN="y"
shift
;;
--no-fail2ban)
FAIL2BAN="n"
shift
;;
-u|--ufw)
UFW="y"
shift
;;
--no-ufw)
UFW="n"
shift
;;
-b|--bootstrap)
BOOTSTRAP="y"
shift
;;
--no-bootstrap)
BOOTSTRAP="n"
shift
;;
-h|--help)
cat << EOL
TKP Masternode installer arguments:
-n --normal : Run installer in normal mode
-a --advanced : Run installer in advanced mode
-i --externalip <address> : Public IP address of VPS
-k --privatekey <key> : Private key to use
-f --fail2ban : Install Fail2Ban
--no-fail2ban : Don't install Fail2Ban
-u --ufw : Install UFW
--no-ufw : Don't install UFW
-b --bootstrap : Sync node using Bootstrap
--no-bootstrap : Don't use Bootstrap
-h --help : Display this help text.
EOL
exit
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
clear
# Set these to change the version of triskelpremium to install
TARBALLURL="https://github.com/triskelpremium/TriskelPremium/releases/download/1.0.0/triskelpremium-1.0.0-x86_64-linux-gnu.tar.gz"
TARBALLNAME="triskelpremium-1.0.0-x86_64-linux-gnu.tar.gz"
BOOTSTRAPURL=""
BOOTSTRAPARCHIVE=""
BWKVERSION="1.0.0"
#!/bin/bash
# Check if we are root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." 1>&2
exit 1
fi
# Check if we have enough memory
if [[ `free -m | awk '/^Mem:/{print $2}'` -lt 850 ]]; then
echo "This installation requires at least 1GB of RAM.";
exit 1
fi
# Check if we have enough disk space
if [[ `df -k --output=avail / | tail -n1` -lt 10485760 ]]; then
echo "This installation requires at least 10GB of free disk space.";
exit 1
fi
# Install tools for dig and systemctl
echo "Preparing installation..."
apt-get install git dnsutils systemd -y > /dev/null 2>&1
# Check for systemd
systemctl --version >/dev/null 2>&1 || { echo "systemd is required. Are you using Ubuntu 16.04?" >&2; exit 1; }
# CHARS is used for the loading animation further down.
CHARS="/-\|"
if [ -z "$EXTERNALIP" ]; then
EXTERNALIP=`dig +short myip.opendns.com @resolver1.opendns.com`
fi
clear
if [ -z "$ADVANCED" ]; then
echo "
___T_
| o o |
|__-__|
/| []|\\
()/|___|\()
|_|_|
/_|_\ ------- MASTERNODE INSTALLER v2 -------+
| |
| You can choose between two installation options: |::
| default and advanced. |::
| |::
| The advanced installation will install and run |::
| the masternode under a non-root user. If you |::
| don't know what that means, use the default |::
| installation method. |::
| |::
| Otherwise, your masternode will not work, and |::
| the TKP Team CANNOT assist you in repairing |::
| it. You will have to start over. |::
| |::
+------------------------------------------------+::
::::::::::::::::::::::::::::::::::::::::::::::::::
"
sleep 5
fi
if [ -z "$ADVANCED" ]; then
read -e -p "Use the Advanced Installation? [N/y] : " ADVANCED
fi
if [[ ("$ADVANCED" == "y" || "$ADVANCED" == "Y") ]]; then
USER=triskelpremium
adduser $USER --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password > /dev/null
INSTALLERUSED="#Used Advanced Install"
echo "" && echo 'Added user "triskelpremium"' && echo ""
sleep 1
else
USER=root
FAIL2BAN="y"
UFW="y"
BOOTSTRAP="n"
INSTALLERUSED="#Used Basic Install"
fi
USERHOME=`eval echo "~$USER"`
if [ -z "$ARGUMENTIP" ]; then
read -e -p "Server IP Address: " -i $EXTERNALIP -e IP
fi
if [ -z "$KEY" ]; then
read -e -p "Masternode Private Key (e.g. 7edfjLCUzGczZi3JQw8GHp434R9kNY33eFyMGeKRymkB56G4324h # THE KEY YOU GENERATED EARLIER) : " KEY
fi
if [ -z "$FAIL2BAN" ]; then
read -e -p "Install Fail2ban? [Y/n] : " FAIL2BAN
fi
if [ -z "$UFW" ]; then
read -e -p "Install UFW and configure ports? [Y/n] : " UFW
fi
if [ -z "$BOOTSTRAP" ]; then
read -e -p "Do you want to use our bootstrap file to speed the syncing process? [Y/n] : " BOOTSTRAP
fi
clear
# Generate random passwords
RPCUSER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
RPCPASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# update packages and upgrade Ubuntu
echo "Installing dependencies..."
apt-get -qq update
apt-get -qq upgrade
apt-get -qq autoremove
apt-get -qq install wget htop unzip
apt-get -qq install build-essential && apt-get -qq install libtool autotools-dev autoconf libevent-pthreads-2.0-5 automake && apt-get -qq install libssl-dev && apt-get -qq install libboost-all-dev && apt-get -qq install software-properties-common && add-apt-repository -y ppa:bitcoin/bitcoin && apt update && apt-get -qq install libdb4.8-dev && apt-get -qq install libdb4.8++-dev && apt-get -qq install libminiupnpc-dev && apt-get -qq install libqt4-dev libprotobuf-dev protobuf-compiler && apt-get -qq install libqrencode-dev && apt-get -qq install git && apt-get -qq install pkg-config && apt-get -qq install libzmq3-dev
apt-get -qq install aptitude
apt-get -qq install libevent-dev
# Install Fail2Ban
if [[ ("$FAIL2BAN" == "y" || "$FAIL2BAN" == "Y" || "$FAIL2BAN" == "") ]]; then
aptitude -y -q install fail2ban
service fail2ban restart
fi
# Install UFW
if [[ ("$UFW" == "y" || "$UFW" == "Y" || "$UFW" == "") ]]; then
apt-get -qq install ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 8155/tcp
yes | ufw enable
fi
# Install TKP daemon
wget $TARBALLURL
tar -xzvf $TARBALLNAME
rm $TARBALLNAME
mv ./triskelpremiumd /usr/local/bin
mv ./triskelpremium-cli /usr/local/bin
mv ./triskelpremium-tx /usr/local/bin
rm -rf $TARBALLNAME
# Create .triskelpremium directory
mkdir $USERHOME/.triskelpremium
# Install bootstrap file
if [[ ("$BOOTSTRAP" == "y" || "$BOOTSTRAP" == "Y" || "$BOOTSTRAP" == "") ]]; then
echo "skipping"
fi
# Create triskelpremium.conf
touch $USERHOME/.triskelpremium/triskelpremium.conf
cat > $USERHOME/.triskelpremium/triskelpremium.conf << EOL
${INSTALLERUSED}
rpcuser=${RPCUSER}
rpcpassword=${RPCPASSWORD}
rpcallowip=127.0.0.1
listen=1
server=1
daemon=1
logtimestamps=1
maxconnections=256
externalip=${IP}
bind=${IP}:8155
masternodeaddr=${IP}
masternodeprivkey=${KEY}
masternode=1
addnode=207.148.6.215
addnode=108.61.193.157
EOL
chmod 0600 $USERHOME/.triskelpremium/triskelpremium.conf
chown -R $USER:$USER $USERHOME/.triskelpremium
sleep 1
cat > /etc/systemd/system/triskelpremium.service << EOL
[Unit]
Description=triskelpremiumd
After=network.target
[Service]
Type=forking
User=${USER}
WorkingDirectory=${USERHOME}
ExecStart=/usr/local/bin/triskelpremiumd -conf=${USERHOME}/.triskelpremium/triskelpremium.conf -datadir=${USERHOME}/.triskelpremium
ExecStop=/usr/local/bin/triskelpremium-cli -conf=${USERHOME}/.triskelpremium/triskelpremium.conf -datadir=${USERHOME}/.triskelpremium stop
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl enable triskelpremium.service
sudo systemctl start triskelpremium.service
clear
cat << EOL
Now, you need to start your masternode. Please go to your desktop wallet
Click the Masternodes tab
Click Start all at the bottom
EOL
read -p "Press Enter to continue after you've done that. " -n1 -s
clear
echo "" && echo "Masternode setup completed." && echo ""