-
Notifications
You must be signed in to change notification settings - Fork 1
/
ubiq-config.sh
180 lines (177 loc) · 9.34 KB
/
ubiq-config.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
#!/bin/bash
node_ip=$(hostname -I|cut -d" " -f 1)
if grep -q 'Raspberry' /proc/device-tree/model; then
hardware=RaspberryPi
arch=32bit
elif grep -q 'Tinker' /proc/device-tree/model; then
hardware=Tinkerboard
arch=32bit
elif grep -q 'XU4' /proc/device-tree/model; then
hardware=OdroidXU4
arch=32bit
elif grep -q 'ODROID-C2' /proc/device-tree/model; then
hardware=OdroidC2
arch=64bit
elif grep -q 'Libre' /proc/device-tree/model; then
hardware=LibreLePotato
arch=64bit
fi
if [ $hardware = RaspberryPi ]; then
rootuser=pi
elif [ $hardware != RaspberryPi ]; then
rootuser=root
fi
whiptail \
--title "Welcome to Ubiq-Config" \
--msgbox "This utility provides options for creating and managing a node for the Ubiq network, as well as helpful tools such as system updates and installing the Shinobi interface." --ok-button Continue 10 49
function advancedMenu() {
while :; do
ADVSEL=$(whiptail --title "ubiq-config" --fb --menu --nocancel " Choose an option from the menu" 19 40 10 \
"1" "Create a new Ubiq node" \
"2" "Show current block information" \
"3" "Update gubiq to latest version" \
"4" "Delete chaindata & re-sync gubiq" \
"5" "Install Shinobi Interface" \
"6" "Install updates to the OS" \
"7" "System information" \
"8" "Reboot the system" \
"9" "Shutdown the system" \
"10" "Exit to Terminal" 3>&1 1>&2 2>&3)
case $ADVSEL in
1)
if [ -f "/usr/bin/gubiq" ]; then
whiptail --title "Ubiq Node Install" --fb --msgbox "gubiq is already installed on your system" 10 45
elif [ "$(whoami)" != $rootuser ]; then
whiptail --title "Block Info" --fb --msgbox "Please log in as "$rootuser" and run 'ubiq-config' again in order to perform this action." 10 47
elif (whiptail --title "Ubiq Node Install" --fb --yesno "Would you like to begin installation of your Ubiq node now?" 10 64); then
if( whiptail --title "Timezone" --fb --msgbox "Please set the correct timezone for your location." 10 54); then
sudo dpkg-reconfigure tzdata
whiptail --title "Timezone" --fb --msgbox "Timezone has been set" 10 25
fi
wget https://raw.githubusercontent.com/maaatttt/ubiq/master/node.sh
sudo chmod +x node.sh
./node.sh
whiptail --title "Ubiq Node Install" --fb --msgbox " You have created a Ubiq node." 10 35
else whiptail --title "Ubiq Node Install" --fb --msgbox "Installation has been canceled." 10 35
fi
;;
2)
if [ -f "/usr/bin/gubiq" ]; then
if [ "$(whoami)" = $rootuser ]; then
whiptail --title "Block Info" --fb --msgbox "Please log in as 'node' and run 'ubiq-config' again in order to perform this action." 10 49
elif ( whiptail --title "Block Info" --fb --yesno "Would you like to display a live view of block information?" 10 64); then
whiptail --title "Block Info" --fb --msgbox "When you are finished, pressing 'Ctrl C' then 'Q' will escape back to 'ubiq-config'" 10 46
less +F /var/log/gubiq.err.log
fi
else
whiptail --title "Block Info" --fb --msgbox "There is no Ubiq node configured on this system." 10 26
fi
;;
3)
if [ -f "/home/pi/auto.sh" ]; then
if [ "$(whoami)" != $rootuser ] ; then
whiptail --title "gubiq Update" --fb --msgbox "Please log in as "$rootuser" and run 'ubiq-config' again in order to perform this action." 10 45
elif ( whiptail --title "gubiq Update" --fb --yesno "Your system is already configured for monthly automatic updates. Would you like to update now anyway?" 10 60); then
wget https://raw.githubusercontent.com/maaatttt/ubiq/master/gu.sh
chmod +x gu.sh
./gu.sh
else whiptail --title "gubiq Update" --fb --msgbox "Update has been canceled." 10 29
fi
elif [ -f "/usr/bin/gubiq" ]; then
if ( whiptail --title "gubiq Update" --fb --yesno "Would you like to update gubiq now?" 10 39); then
wget https://raw.githubusercontent.com/maaatttt/ubiq/master/gu.sh
chmod +x gu.sh
./gu.sh
whiptail --title "gubiq Update" --fb --msgbox "Please reboot your system from the main menu" 10 48
else whiptail --title "gubiq Update" --fb --msgbox "Update has been canceled." 10 29
fi
else whiptail --title "gubiq Update" --fb --msgbox "There is no Ubiq node configured on this system." 10 52
fi
;;
4)
if [ -f "/usr/bin/gubiq" ]; then
if [ "$(whoami)" = $rootuser ] ; then
whiptail --title "Resync" --fb --msgbox "Please log in as 'node' and run 'ubiq-config' again in order to perform this action." 10 49
elif ( whiptail --title "Resync" --fb --yesno "Would you like to delete all gubiq data and sync the blockchain from scratch?" 10 43); then
sudo apt update
sudo supervisorctl stop gubiq
gubiq removedb
whiptail --title "Resync" --fb --msgbox "Your chain data has been deleted. Please reboot the system from the main menu." 10 45
else
whiptail --title "Resync" --fb --msgbox "Your chain data has not been deleted." 10 41
fi
else
whiptail --title "gubiq Update" --fb --msgbox "There is no Ubiq node configured on this system." 10 52
fi
;;
5)
if [ "$(whoami)" != $rootuser ]; then
whiptail --title "Shinobi Interface Installation" --fb --msgbox "Please log in as "$rootuser" and run 'ubiq-config' again to perform this action." 10 45
elif [ "$(whoami)" = $rootuser ]; then
if [ $hardware = "RaspberryPi" ] && [ -d "/home/pi/shinobi-interface" ]; then
whiptail --title "Shinobi Interface Installation" --fb --msgbox "Shinobi Interface is already installed on your system. Use Shinobi by visiting "$node_ip":8888 in a browser" 11 58
elif [ $hardware != "RaspberryPi" ] && [ -d "/root/shinobi-interface" ]; then
whiptail --title "Shinobi Interface Installation" --fb --msgbox "Shinobi Interface is already installed on your system. Use Shinobi by visiting "$node_ip":8888 in a browser" 11 58
elif (whiptail --title "Shinobi Interface Installation" --fb --yesno "Would you like to install Shinobi Interface now?" 10 52); then
clear
wget https://raw.githubusercontent.com/maaatttt/ubiq/master/shinobi.sh
sudo chmod +x shinobi.sh
./shinobi.sh
else
whiptail --title "Shinobi Interface Installation" --fb --msgbox "Shinobi Interface installation canceled" 10 44
fi
fi
;;
6)
if (whiptail --title "System Update" --fb --yesno "Would you like to update your system now?" 10 45); then
clear
sudo apt update
sudo apt upgrade -y
sudo apt full-upgrade
whiptail --title "System Update" --fb --msgbox "Any available updates have been installed. Please reboot the system from the main menu for any changes to take effect." 11 48
else
whiptail --title "System Update" --fb --msgbox "Updates have not been installed" 10 35
fi
;;
7)
if [ -f "/usr/bin/gubiq" ]; then
touch info.txt
echo "Your IP Address is -" | tee -a info.txt 1>/dev/null
echo $node_ip | tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
echo "Your gubiq version information is -" | tee -a info.txt 1>/dev/null
gubiq version | tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
echo "Your SSD storage is -"| tee -a info.txt 1>/dev/null
df /dev/sda -h | tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
echo " "| tee -a info.txt 1>/dev/null
whiptail --textbox --fb info.txt 30 60
sudo rm info.txt
clear
else whiptail --title "Block Info" --fb --msgbox "There is no Ubiq node configured on this system." 10 52
fi
;;
8)
if (whiptail --title "System Reboot" --fb --yesno "Would you like to reboot immediately?" 10 41); then
sudo reboot
else
whiptail --title "System Reboot" --fb --msgbox "Reboot Canceled" 10 19
fi
;;
9)
if (whiptail --title "System Shutdown" --fb --yesno "Would you like to shut down immediately?" 10 44); then
sudo shutdown -h now
else
whiptail --title "System Shutdown" --fb --msgbox "Shutdown Canceled" 10 21
fi
;;
10)
break
;;
esac
done
}
advancedMenu