-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path00_definode.sh
More file actions
executable file
·255 lines (216 loc) · 5.55 KB
/
00_definode.sh
File metadata and controls
executable file
·255 lines (216 loc) · 5.55 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
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
#!/bin/sh
######################################### Var's ########################################################
IFCONFIG=$(ifconfig)
######################################### Root check ########################################################
# Check if root
if [ "$(whoami)" != "root" ]; then
whiptail --msgbox "Sorry you are not root. You must type: sudo sh 00_definode.sh" 20 45 1
exit
fi
######################################### Whiptail check ########################################################
if [ $(dpkg-query -W -f='${Status}' whiptail 2>/dev/null | grep -c "ok installed") -eq 1 ];
then
sleep 0
else
apt-get install whiptail -y
fi
######################################### Tools menu ########################################################
do_01_system_preparation() {
echo 01_system_preparation
sudo -E sh 01_system_preparation.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to reboot Raspberry PI"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
sudo reboot
}
do_02_download_snapshot() {
echo 02_download_snapshot
sudo -E sh 02_download_snapshot.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_03_build_images() {
echo 03_build_images
sudo -E sh 03_build_images.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_04_run_definode() {
echo 04_run_definode
sudo -E sh 04_run_definode.sh
}
do_05_stop_definode() {
echo 05_stop_definode
sudo -E sh 07_stop_definode.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_06_repair_definode() {
echo 06_repair_definode
sudo -E sh 08_repair_definode.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_07_backup_defiwallet() {
echo 07_backup_defiwallet
sudo -E sh 09_backup_defiwallet.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_08_show_defi_chain_logs() {
echo 08_show_defi_chain_logs
sudo -E sh 05_show_defi_chain_logs.sh
}
do_09_show_defi_wallet_logs() {
echo 09_show_defi_wallet_logs
sudo -E sh 06_show_defi_wallet_logs.sh
}
do_10_init_defihome() {
echo 10_init_defihome
sudo -E sh 10_init_defihome.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to the terminal"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
}
do_11_update_images() {
echo 11_update_images
sudo -E sh 11_update_images.sh
sudo -E sh 07_stop_definode.sh
sudo -E sh 04_run_definode.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_12_create_shortcuts() {
echo 12_create_shortcuts
sudo -E sh 12_create_shortcuts.sh
do_show_menu
}
do_13_update_defi_scripts() {
echo 13_update_defi_scripts
sudo -E sh 13_update_defi_scripts.sh
### wait for SPACE key pressed
hold=' '
echo "Press 'SPACE' to return to main menu"
tty_state=$(stty -g)
stty -icanon
until [ -z "${hold#$in}" ] ; do
in=$(dd bs=1 count=1 </dev/tty 2>/dev/null)
done
stty "$tty_state"
#####
do_show_menu
}
do_finish() {
echo "Goodbye"
}
#########################################Start########################################################
do_show_menu() {
OPTION=$(whiptail --title "DeFiNode" --menu "Choose your option:" 23 60 15 \
"" "DeFi home: '"$DEFI_HOME"'" \
"" "*********************************" \
"1" "System preparation with reboot" \
"2" "Download Snapshot (5 min)" \
"3" "Build chain and app (2.5 hours)" \
"4" "Run DeFi Node" \
"5" "Stop DeFi Node" \
"6" "Repair DeFi Node" \
"7" "Backup DeFi Wallet" \
"8" "Show Defi Chain logs" \
"9" "Show Wallet logs" \
"10" "Set DeFi Home" \
"11" "Update DeFiNode and DeFiWallet" \
"12" "Create Shortcuts" \
"13" "Update DeFi scripts from GitHub" 3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
do_finish
elif [ $RET -eq 0 ]; then
case "$OPTION" in
1) do_01_system_preparation ;;
2) do_02_download_snapshot ;;
3) do_03_build_images ;;
4) do_04_run_definode ;;
5) do_05_stop_definode ;;
6) do_06_repair_definode ;;
7) do_07_backup_defiwallet ;;
8) do_08_show_defi_chain_logs ;;
9) do_09_show_defi_wallet_logs ;;
10) do_10_init_defihome ;;
11) do_11_update_images ;;
12) do_12_create_shortcuts ;;
13) do_13_update_defi_scripts ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac
else
exit 1
fi
}
do_show_menu