This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MNCommander.sh
329 lines (261 loc) · 6.74 KB
/
MNCommander.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
#LocalVariable
declare -a installable=("BRO" "PIVX" "XMCC" "SCORE")
function red {
echo -e "$(tput bold; tput setaf 1)$1$(tput sgr0)"
}
function igreen {
echo -e "$(tput bold; tput setaf 0; tput setab 2)$1$(tput sgr0)"
}
function ired {
echo -e "$(tput bold; tput setaf 3; tput setab 1)$1$(tput sgr0)"
}
function green {
echo -e "$(tput bold; tput setaf 2)$1$(tput sgr0)"
}
function yellow {
echo -e "$(tput bold; tput setaf 3)$1$(tput sgr0)"
}
function asciiart() {
clear
tput bold; tput setaf 1
cat << "EOF"
__ __ _____ _______ ______ _____ _ _ ____ _____ ______
| \/ | /\ / ____|__ __| ____| __ \| \ | |/ __ \| __ \| ____|
| \ / | / \ | (___ | | | |__ | |__) | \| | | | | | | | |__
| |\/| | / /\ \ \___ \ | | | __| | _ /| . ` | | | | | | | __|
| | | |/ ____ \ ____) | | | | |____| | \ \| |\ | |__| | |__| | |____
|_| |_/_/__ _\_\_____/__ |_| _|______|_| _\_\_|_\_|\____/|_____/|______|
/ ____/ __ \| \/ | \/ | /\ | \ | | __ \| ____| __ \
| | | | | | \ / | \ / | / \ | \| | | | | |__ | |__) |
| | | | | | |\/| | |\/| | / /\ \ | . ` | | | | __| | _ /
| |___| |__| | | | | | | |/ ____ \| |\ | |__| | |____| | \ \
\_____\____/|_| |_|_| |_/_/ \_\_| \_|_____/|______|_| \_\
@chubja glaxer95@gmail.com
EOF
tput sgr0
}
function menu() {
asciiart
show_option
read_option
}
function one() {
asciiart
show_installable
read_installable
}
function two() {
asciiart
show_selectable
read_selectable
}
function three() {
git pull
menu
}
function run() {
asciiart
crypto=$1
show_runcmd $crypto
read_runcmd $crypto
}
function cmd_install() {
clear
crypto=$1
source ./${crypto}_qtbuild/${crypto}.sh
${crypto}_install
read -p " Press [Enter] To Exit ..."
run ${crypto}
}
function cmd_update() {
clear
crypto=$1
pushd ./${crypto}_qtbuild/
git pull
popd
read -p " Press [Enter] To Exit ..."
run ${crypto}
}
function cmd_run() {
clear
crypto=$1
source ./${crypto}_qtbuild/${crypto}.sh
${crypto}_run
read -p " Press [Enter] To Exit ..."
run ${crypto}
}
function cmd_stop() {
clear
crypto=$1
source ./${crypto}_qtbuild/${crypto}.sh
${crypto}_stop
read -p " Press [Enter] To Exit ..."
run ${crypto}
}
function cmd_edit() {
clear
crypto=$1
source ./${crypto}_qtbuild/${crypto}.sh
config=$( ${crypto}_conf )
if [ -d "$config" ]; then
touch $config
fi
> $config
yellow " Enter rpcuser"
read -p " > rpcuser : " rpcuser
echo
yellow " Enter rpcpassword"
read -p " > rpcpassword : " rpcpassword
echo
yellow " Enter rpcallowip"
read -p " > rpcallowip : " rpcallowip
echo
yellow " Enter daemon"
read -p " > daemon : " daemon
echo
yellow " Enter server"
read -p " > server : " server
echo
yellow " Enter listen"
read -p " > listen : " listen
echo
yellow " Enter masternode"
read -p " > masternode : " masternode
echo
yellow " Enter masternodeprivkey"
read -p " > masternodeprivkey : " masternodeprivkey
echo
yellow " Enter externalip"
read -p " > externalip : " externalip
echo
echo "rpcuser=$rpcuser" >> $config
sed -i "$ a rpcpassword=$rpcpassword" $config
sed -i "$ a rpcallowip=$rpcallowip" $config
sed -i "$ a daemon=$daemon" $config
sed -i "$ a server=$server" $config
sed -i "$ a listen=$listen" $config
sed -i "$ a masternode=$masternode" $config
sed -i "$ a masternodeprivkey=$masternodeprivkey" $config
sed -i "$ a externalip=$externalip" $config
echo
red "*** Check your Conf ***"
echo
cat $config
echo
read -p " Press [Enter] To Exit ..."
run ${crypto}
}
function show_runcmd() {
crypto=${1^}
tput bold; tput setaf 3
echo " ---------------------"
echo " ${crypto}"
echo " ---------------------"
echo
echo " 1) Install ${crypto}"
echo " 2) Edit Conf ${crypto}"
echo " 3) Start ${crypto}"
echo " 4) Kill ${crypto}"
echo " 5) Update ${crypto}"
echo " 0) Return To Menu"
tput sgr0
}
function read_runcmd() {
crypto=${1,,}
local choice
read -p " Enter choice [1 2]: " choice
case $choice in
0) two;;
1) cmd_install $crypto;;
2) cmd_edit $crypto;;
3) cmd_run $crypto;;
4) cmd_stop $crypto;;
5) cmd_update $crypto;;
*) run $crypto
esac
}
function show_selectable() {
tput bold; tput setaf 3
echo " ---------------------"
echo " Installed"
echo " ---------------------"
echo
for c in "${installable[@]}"
do
DIRECTORY=${c,,}_qtbuild
if [ -d "$DIRECTORY" ]; then
echo " * $c"
fi
done
echo " 0) Exit"
tput sgr0
}
function read_selectable() {
local choice
read -p " Enter Crypto [BRO..0] : " choice
case $choice in
0) menu ;;
esac
if [ ! $choice ]; then
menu
else
run $choice
fi
}
function install_components() {
crypto=${1,,}
gitaddr="https://github.com/MinseokOh/${crypto}_qtbuild.git"
git clone $gitaddr
read -p " Press [Enter] To Exit ..."
one
}
#OPTIONS
function show_installable() {
tput bold; tput setaf 3
for c in "${installable[@]}"
do
DIRECTORY=${c,,}_qtbuild
if [ ! -d "$DIRECTORY" ]; then
echo " * $c"
fi
done
echo " 0) Exit"
tput sgr0
}
function read_installable() {
local choice
read -p " Enter Crypto [BRO..0] : " choice
case $choice in
0) menu ;;
esac
if [ ! $choice ]; then
menu
else
install_components $choice
fi
}
function show_option() {
tput bold; tput setaf 3
echo " ---------------------"
echo " OPTIONS "
echo " ---------------------"
echo
echo " 1) Install Components"
echo " 2) Select Components"
echo " 3) Update MNCommander"
echo " 0) Exit"
tput sgr0
}
function read_option() {
local choice
read -p " Enter choice [1 2]: " choice
case $choice in
1) one ;;
2) two ;;
3) three ;;
0) exit 0;;
*) echo -e "$(red " Incorrect option!")" && sleep 1
esac
}
menu