-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSetupNodeMiner.sh
79 lines (66 loc) · 2.11 KB
/
SetupNodeMiner.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
#!/bin/bash
# Easy Setup Script for NodeJS Nimiq Miner
#Get Settings
echo 'Please enter your domain: '
read nimiqDomain
echo 'Please enter the number of Miningthreads: '
read nimiqThreads
echo 'Enter the name of the script to be generated(e.g. mine.sh): '
read nimiqScript
echo 'Enter Wallet Address (NOT SEED): '
read nimiqAddress
echo 'Enter email address for letsencrypt: '
read nimiqEmail
#Check for possible conflicts
toremove=""
declare -a rmvdeps=("apache2" "nginx")
for i in "${rmvdeps[@]}"
do
dpkg -s "$i" &> /dev/null
if [ $? -eq 1 ]; then
echo "$i Check Complete"
else
read -p "$i detected. Do you want to remove it?(Type:YES) " rmvi
if [ "$rmvi" = "YES" ]; then
echo "Removing $i!"
toremove="$i $toremove"
fi
fi
done
#remove possible conflicts if installed (and selected to remove)
if [ "$toremove" != "" ]; then
sudo apt-get -y purge $(echo "$toremove" | xargs)
fi
#Make sure system is updated
sudo apt-get update
sudo apt-get -y upgrade
#Install requirements
sudo apt-get install -y curl git build-essential
#Setup NodeJS
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
#Add Gulp globally
sudo npm install -g gulp
#Get the Nimiq project
git clone https://github.com/nimiq-network/core
#Build Nimiq project
cd core
npm install
npm run build
cd clients/nodejs
npm install
cd ../../
npm run prepare
#setup Letsencrypt
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:certbot/certbot
sudo apt-get update
sudo apt-get install -y certbot
#Get SSL Cert
sudo certbot --non-interactive --agree-tos -m $nimiqEmail certonly --standalone --preferred-challenges http -d $nimiqDomain
#Generate Mining Runscript
cd ..
touch $nimiqScript
chmod +x $nimiqScript
echo "cd core/clients/nodejs/" >> $nimiqScript
echo "env UV_THREADPOOL_SIZE=$nimiqThreads node index.js --host=$nimiqDomain --wallet-address=\"$nimiqAddress\" --port=5566 --cert=/etc/letsencrypt/live/$nimiqDomain/cert.pem --key=/etc/letsencrypt/live/$nimiqDomain/privkey.pem --miner=$nimiqThreads --statistics=10" >> $nimiqScript