forked from liberty-rowland/Nimiq-Install-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-install.sh
More file actions
146 lines (120 loc) · 3.18 KB
/
auto-install.sh
File metadata and controls
146 lines (120 loc) · 3.18 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
#!/bin/bash
################################################################################
# Author: Bhlynd
# Program: Install Nimiq on Ubuntu
# Flavor: Porky Pool (https://www.porkypool.com)
################################################################################
output() {
printf "\E[0;33;40m"
echo $1
printf "\E[0m"
}
displayErr() {
echo
echo $1;
echo
exit 1;
}
mkdir $HOME/nimiq
cd $HOME/nimiq
IS_ROOT=false
if [ "$EUID" -eq 0 ]; then
output "WARNING: It looks like you're running as root. It is highly recommended NOT to"
output "run miners as root, as you may open yourself to vulnerabilities!"
while [[ ! $CONTINUE =~ ^[yn]$ ]]; do
read -e -s -n 1 -p "Continue as root anyway? [y/N] " CONTINUE
if [ -z "$CONTINUE" ]; then
CONTINUE='n'
else
CONTINUE=$(echo "$CONTINUE" | tr '[:upper:]' '[:lower:]')
fi
done
if [[ $CONTINUE == "n" ]]; then
exit
fi
IS_ROOT=true
fi
output " "
output " "
output "Please double check before hitting enter! You only have one shot at these!"
output " "
POOL=us-east.porkypool.com:8444
THREADS=$(getconf _NPROCESSORS_ONLN)
WALLET="NQ73 LLJ3 YC4T 4N64 TPEM S6RF J3L4 0GRR 5U12"
EXTRADATA=$HOSTNAME
STATISTICS=15
output " "
output "Making sure everything is up to date."
output " "
sleep 3
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y autoremove
output " "
output "Adding nodejs sources."
output " "
sleep 3
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
output " "
output "Installing required dependencies."
output " "
sleep 3
sudo apt-get install -y git build-essential python2.7 python-dev nodejs unzip
output " "
output "Downloading Nimiq core."
output " "
sleep 3
git clone https://github.com/ryan-rowland/core.git
output " "
output "Building Nimiq core client."
output " "
sleep 3
cd core
if [ IS_ROOT == true ]; then
npm install --unsafe-perm
else
npm install
fi
npm run prepare
output " "
output "Building launch scripts."
output " "
sleep 3
cd ..
echo '#!/bin/bash
SCRIPT_PATH=$(dirname "$0")/core
$SCRIPT_PATH/clients/nodejs/nimiq "$@"' > miner
chmod u+x miner
echo '#!/bin/bash
UV_THREADPOOL_SIZE='"${THREADS}"' ./miner --dumb --pool='"${POOL}"' --miner='"${THREADS}"' --wallet-address="'"${WALLET}"'" --extra-data="'"${EXTRADATA}"'" --statistics='"${STATISTICS}"'' > start
chmod u+x start
output " "
output "Downloading consensus."
output " "
sleep 3
if [ ! -d "./main-full-consensus" ]; then
wget https://github.com/ryan-rowland/Nimiq-Install-Script/raw/master/main-full-consensus.tar.gz
tar -xvf main-full-consensus.tar.gz
rm main-full-consensus.tar.gz
fi
output "Congratulations! If everything went well you can now start mining."
output " "
output "To start the miner type ./start"
output " "
output "If you need to change any settings, you can do so by editing the start file."
sleep 3
output " "
output "Configuring crontab"
output " "
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "@reboot $HOME/nimiq > $HOME/nimiq/log.txt" >> mycron
#install new cron file
crontab mycron
rm mycron
output " "
output "Starting miner ./start"
output " "
$HOME/nimiq/start > $HOME/nimiq/log.txt