-
Notifications
You must be signed in to change notification settings - Fork 41
/
update-monero.sh
231 lines (198 loc) · 8.43 KB
/
update-monero.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
#!/bin/bash
#Error Log:
touch /home/pinodexmr/debug.log
echo "
####################
" 2>&1 | tee -a /home/pinodexmr/debug.log
echo "Start setup-update-monero.sh script $(date)" 2>&1 | tee -a /home/pinodexmr/debug.log
echo "
####################
" 2>&1 | tee -a /home/pinodexmr/debug.log
#Download variable for current monero release version
wget -q https://raw.githubusercontent.com/shermand100/PiNodeXMR/master/release.sh -O /home/pinodexmr/release.sh
#Permission Setting
chmod 755 /home/pinodexmr/release.sh
#Load boot status - condition the node was last run
. /home/pinodexmr/bootstatus.sh
#Import Variable: Light-mode true/false
. /home/pinodexmr/variables/light-mode.sh
echo "Light-Mode value is: $LIGHTMODE" >>/home/pinodexmr/debug.log
#Load Variables
. /home/pinodexmr/release.sh
#Establish OS 32 or 64 bit
CPU_ARCH=`getconf LONG_BIT`
echo "OS getconf LONG_BIT $CPU_ARCH" >> /home/pinodexmr/debug.log
if [[ $CPU_ARCH -eq 64 ]]
then
echo "ARCH: 64-bit"
elif [[ $CPU_ARCH -eq 32 ]]
then
echo "ARCH: 32-bit"
else
echo "OS Unknown"
fi
sleep 3
##Configure temporary Swap file if needed (swap created is not persistant and only for compiling monero. It will unmount on reboot)
if (whiptail --title "PiNode-XMR Monero Updater" --yesno "For Monero to compile successfully 2GB of RAM is required.\n\nIf your device does not have 2GB RAM it can be artificially created with a swap file\n\nDo you have 2GB RAM on this device?\n\n* YES\n* NO - I do not have 2GB RAM (create a swap file)" 18 60); then
echo -e "\e[32mSwap file unchanged\e[0m"
sleep 3
else
sudo fallocate -l 2G /swapfile 2>&1 | tee -a /home/pinodexmr/debug.log
sudo chmod 600 /swapfile 2>&1 | tee -a /home/pinodexmr/debug.log
sudo mkswap /swapfile 2>&1 | tee -a /home/pinodexmr/debug.log
sudo swapon /swapfile 2>&1 | tee -a /home/pinodexmr/debug.log
echo -e "\e[32mSwap file of 2GB Configured and enabled\e[0m"
free -h
sleep 3
fi
#ubuntu /dev/null odd requiremnt to set permissions
sudo chmod 666 /dev/null
sleep 2
#Stop Node to make system resources available.
sudo systemctl stop blockExplorer.service
sudo systemctl stop moneroPrivate.service
sudo systemctl stop moneroMiningNode.service
sudo systemctl stop moneroTorPrivate.service
sudo systemctl stop moneroTorPublic.service
sudo systemctl stop moneroPublicFree.service
sudo systemctl stop moneroI2PPrivate.service
sudo systemctl stop moneroCustomNode.service
sudo systemctl stop moneroPublicRPCPay.service
echo "Monero node stop command sent, allowing 30 seconds for safe shutdown"
sleep "30"
echo "Deleting Old Version"
rm -rf /home/pinodexmr/monero/
sleep "2"
if [[ $LIGHTMODE = FALSE ]]
then
# ********************************************
# ******START OF MONERO SOURCE BULD******
# ********************************************
echo "manual build of gtest for --- Monero" 2>&1 | tee -a /home/pinodexmr/debug.log
sudo apt-get install libgtest-dev -y 2>&1 | tee -a /home/pinodexmr/debug.log
cd /usr/src/gtest
sudo cmake . 2>&1 | tee -a /home/pinodexmr/debug.log
sudo make 2>&1 | tee -a /home/pinodexmr/debug.log
sudo mv lib/libg* /usr/lib/
cd
echo "Check dependencies installed for --- Monero" 2>&1 | tee -a /home/pinodexmr/debug.log
sudo apt-get update
sudo apt-get install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-all-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev ccache doxygen graphviz -y 2>&1 | tee -a /home/pinodexmr/debug.log
echo -e "\e[32mDownloading Monero \e[0m"
sleep 2
git clone --recursive https://github.com/monero-project/monero
echo -e "\e[32mBuilding Monero \e[0m"
echo -e "\e[32m****************************************************\e[0m"
echo -e "\e[32m****************************************************\e[0m"
echo -e "\e[32m***This will take a while - Hardware Dependent***\e[0m"
echo -e "\e[32m****************************************************\e[0m"
echo -e "\e[32m****************************************************\e[0m"
sleep 10
cd monero && git submodule init && git submodule update
git checkout $RELEASE
git submodule sync && git submodule update
USE_SINGLE_BUILDDIR=1 make 2>&1 | tee -a /home/pinodexmr/debug.log
cd
#Make dir .bitmonero to hold lmdb. Needs to be added before drive mounted to give mount point. Waiting for monerod to start fails mount.
mkdir .bitmonero 2>&1 | tee -a /home/pinodexmr/debug.log
# ********************************************
# ********END OF MONERO SOURCE BULD **********
# ********************************************
fi
if [[ $LIGHTMODE = TRUE ]]
then
#********************************************
#**********START OF Monero BINARY USE********
#********************************************
echo "Downloading pre-built Monero from get.monero" 2>&1 | tee -a /home/pinodexmr/debug.log
#Make standard location for Monero
mkdir -p ~/monero/build/release/bin
if [[ $CPU_ARCH -eq 64 ]]
then
#Download 64-bit Monero
wget https://downloads.getmonero.org/cli/linuxarm8
#Make temp folder to extract binaries
mkdir temp && tar -xvf linuxarm8 -C ~/temp
#Move Monerod files to standard location
mv /home/pinodexmr/temp/monero-aarch64-linux-gnu-v0.18*/monero* /home/pinodexmr/monero/build/release/bin/
rm linuxarm8
rm -R /home/pinodexmr/temp/
else
#Download 32-bit Monero
wget https://downloads.getmonero.org/cli/linuxarm7
#Make temp folder to extract binaries
mkdir temp && tar -xvf linuxarm7 -C ~/temp
#Move Monerod files to standard location
mv /home/pinodexmr/temp/monero-arm-linux-gnueabihf-v0.18*/monero* /home/pinodexmr/monero/build/release/bin/
rm linuxarm7
rm -R ~/temp/
fi
#********************************************
#*******END OF Monero BINARY USE*******
#********************************************
fi
#Make dir .bitmonero to hold lmdb. Needs to be added before drive mounted to give mount point. Waiting for monerod to start fails mount.
mkdir .bitmonero 2>&1 | tee -a /home/pinodexmr/debug.log
#Clean-up used downloaded files
rm -R ~/temp
#Update system version number
echo "#!/bin/bash
CURRENT_VERSION=$NEW_VERSION" > /home/pinodexmr/current-ver.sh
#cleanup old version number file
rm /home/pinodexmr/xmr-new-ver.sh
#Define Restart Monero Node
# Key - BOOT_STATUS
# 2 = idle
# 3 || 5 = private node || mining node
# 4 = tor
# 6 = Public RPC pay
# 7 = Public free
# 8 = I2P
# 9 tor public
if [ $BOOT_STATUS -eq 2 ]
then
whiptail --title "Monero Update Complete" --msgbox "Update complete, Node ready for start. See web-ui at $(hostname -I) to select mode." 16 60
fi
if [ $BOOT_STATUS -eq 3 ]
then
sudo systemctl start moneroPrivate.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 4 ]
then
sudo systemctl start moneroTorPrivate.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 5 ]
then
sudo systemctl start moneroMiningNode.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 6 ]
then
sudo systemctl start moneroPublicRPCPay.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 7 ]
then
sudo systemctl start moneroPublicFree.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 8 ]
then
sudo systemctl start moneroI2PPrivate.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
if [ $BOOT_STATUS -eq 9 ]
then
sudo systemctl start moneroTorPublic.service
whiptail --title "Monero Update Complete" --msgbox "Update complete, Your Monero Node has resumed." 16 60
fi
##End debug log
echo "Update Complete" 2>&1 | tee -a /home/pinodexmr/debug.log
sleep 5
echo "####################" 2>&1 | tee -a /home/pinodexmr/debug.log
echo "End setup-update-monero.sh script $(date)" 2>&1 | tee -a /home/pinodexmr/debug.log
echo "####################" 2>&1 | tee -a /home/pinodexmr/debug.log
rm ~/release.sh
./setup.sh