-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathquestions_combined.sh
373 lines (319 loc) · 9.83 KB
/
questions_combined.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#####################################################
# Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox
# Updated by cryptopool.builders for crypto use...
#####################################################
source /etc/functions.sh
source /etc/multipool.conf
if [ -f "$STORAGE_ROOT/yiimp/.wireguard_public.conf" ]; then
source "$STORAGE_ROOT/yiimp/.wireguard_public.conf"
else
wireguard='false'
fi
dialog --title "Using Sub-Domain" \
--yesno "Are you using a sub-domain for the main website domain? Example pool.example.com?" 7 60
response=$?
case $response in
0) UsingSubDomain=yes;;
1) UsingSubDomain=no;;
255) echo "[ESC] key pressed.";;
esac
if [ -z "${DomainName:-}" ]; then
DEFAULT_DomainName=example.com
input_box "Domain Name" \
"Enter your domain name. If using a subdomain enter the full domain as in pool.example.com
\n\nDo not add www. to the domain name.
\n\nDomain Name:" \
$DEFAULT_DomainName \
DomainName
if [ -z "$DomainName" ]; then
# user hit ESC/cancel
exit
fi
fi
if [ -z "${StratumURL:-}" ]; then
DEFAULT_StratumURL=stratum.$DomainName
input_box "Stratum URL" \
"Enter your stratum URL. It is recommended to use another subdomain such as stratum.$DomainName
\n\nDo not add www. to the domain name.
\n\nStratum URL:" \
$DEFAULT_StratumURL \
StratumURL
if [ -z "$StratumURL" ]; then
# user hit ESC/cancel
exit
fi
fi
dialog --title "Install SSL" \
--yesno "Would you like the system to install SSL automatically?" 7 60
response=$?
case $response in
0) InstallSSL=yes;;
1) InstallSSL=no;;
255) echo "[ESC] key pressed.";;
esac
if [ -z "${SupportEmail:-}" ]; then
DEFAULT_SupportEmail=root@localhost
input_box "System Email" \
"Enter an email address for the system to send alerts and other important messages.
\n\nSystem Email:" \
$DEFAULT_SupportEmail \
SupportEmail
if [ -z "$SupportEmail" ]; then
# user hit ESC/cancel
exit
fi
fi
if [ -z "${AdminPanel:-}" ]; then
DEFAULT_AdminPanel=AdminPortal
input_box "Admin Panel Location" \
"Enter your desired location name for admin access..
\n\nOnce set you will access the YiiMP admin at $DomainName/site/AdminPortal
\n\nDesired Admin Panel Location:" \
$DEFAULT_AdminPanel \
AdminPanel
if [ -z "$AdminPanel" ]; then
# user hit ESC/cancel
exit
fi
fi
dialog --title "Use AutoExchange" \
--yesno "Would you like the stratum to be built with autoexchange enabled?" 7 60
response=$?
case $response in
0) AutoExchange=yes;;
1) AutoExchange=no;;
255) echo "[ESC] key pressed.";;
esac
dialog --title "Use Dedicated Coin Ports" \
--yesno "Would you like YiiMP to be built with dedicated coin ports?" 7 60
response=$?
case $response in
0) CoinPort=yes;;
1) CoinPort=no;;
255) echo "[ESC] key pressed.";;
esac
if [ -z "${PublicIP:-}" ]; then
if pstree -p | egrep --quiet --extended-regexp ".*sshd.*\($$\)"; then
DEFAULT_PublicIP=$(echo $SSH_CLIENT | awk '{ print $1}')
else
DEFAULT_PublicIP=192.168.0.1
fi
input_box "Your Public IP" \
"Enter your public IP from the remote system you will access your admin panel from.
\n\nWe have guessed your public IP from the IP used to access this system.
\n\nGo to whatsmyip.org if you are unsure this is your public IP.
\n\nYour Public IP:" \
${DEFAULT_PublicIP} \
PublicIP
if [ -z "$PublicIP" ]; then
# user hit ESC/cancel
exit
fi
fi
# Get the IP addresses of the local network interface(s).
if [ -z "${DBInternalIP:-}" ]; then
DEFAULT_DBInternalIP='10.0.0.2'
input_box "DB Server Private IP" \
"Enter the private IP address of the DB (this) Server, as given to you by your provider.
\n\nIf you do not have one from your provider leave the Wireguard default below.
\n\nPrivate IP address:" \
$DEFAULT_DBInternalIP \
DBInternalIP
if [ -z "$DBInternalIP" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${WebUser:-}" ]; then
DEFAULT_WebUser='yiimpadmin'
input_box "Web Server User Name" \
"Enter the user name for the Web Server.
\n\nThis is required for setup to complete.
\n\nWeb Server User Name:" \
$DEFAULT_WebUser \
WebUser
if [ -z "$WebUser" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${WebPass:-}" ]; then
DEFAULT_WebPass='password'
input_box "Web Server User Password" \
"Enter the users password for the Web Server.
\n\nThis is required for setup to complete.
\n\nWhen pasting your password CTRL+V does NOT work, you must either SHIFT+RightMouseClick or SHIFT+INSERT!!
\n\nWeb Server User Password:" \
$DEFAULT_WebPass \
WebPass
if [ -z "$WebPass" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${WebInternalIP:-}" ]; then
DEFAULT_WebInternalIP='10.0.0.3'
input_box "Web Server Private IP" \
"Enter the private IP address of the Web Server, as given to you by your provider.
\n\nIf you do not have one from your provider leave the Wireguard default below.
\n\nPrivate IP address:" \
$DEFAULT_WebInternalIP \
WebInternalIP
if [ -z "$WebInternalIP" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${DaemonUser:-}" ]; then
DEFAULT_DaemonUser='yiimpadmin'
input_box "Daemon Server User Name" \
"Enter the user name for the Daemon Server.
\n\nThis is required for setup to complete.
\n\nDaemon Server User Name:" \
$DEFAULT_DaemonUser \
DaemonUser
if [ -z "$DaemonUser" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${DaemonPass:-}" ]; then
DEFAULT_DaemonPass='password'
input_box "Daemon Server User Password" \
"Enter the users password for the Daemon Server.
\n\nThis is required for setup to complete.
\n\nWhen pasting your password CTRL+V does NOT work, you must either SHIFT+RightMouseClick or SHIFT+INSERT!!
\n\nDaemon Server User Password:" \
$DEFAULT_DaemonPass \
DaemonPass
if [ -z "$DaemonPass" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${DaemonInternalIP:-}" ]; then
DEFAULT_DaemonInternalIP='10.0.0.5'
input_box "Daemon Server Private IP" \
"Enter the private IP address of the Daemon Server, as given to you by your provider.
\n\nIf you do not have one from your provider leave the Wireguard default below.
\n\nPrivate IP address:" \
$DEFAULT_DaemonInternalIP \
DaemonInternalIP
if [ -z "$DaemonInternalIP" ]; then
user hit ESC/cancel
exit
fi
fi
if [ -z "${DBRootPassword:-}" ]; then
DEFAULT_DBRootPassword=$(openssl rand -base64 29 | tr -d "=+/")
input_box "Database Root Password" \
"Enter your desired database root password.
\n\nYou may use the system generated password shown.
\n\nDesired Database Password:" \
$DEFAULT_DBRootPassword \
DBRootPassword
if [ -z "$DBRootPassword" ]; then
# user hit ESC/cancel
exit
fi
fi
if [ -z "${PanelUserDBPassword:-}" ]; then
DEFAULT_PanelUserDBPassword=$(openssl rand -base64 29 | tr -d "=+/")
input_box "Database Panel Password" \
"Enter your desired database panel password.
\n\nYou may use the system generated password shown.
\n\nDesired Database Password:" \
$DEFAULT_PanelUserDBPassword \
PanelUserDBPassword
if [ -z "$PanelUserDBPassword" ]; then
# user hit ESC/cancel
exit
fi
fi
if [ -z "${StratumUserDBPassword:-}" ]; then
DEFAULT_StratumUserDBPassword=$(openssl rand -base64 29 | tr -d "=+/")
input_box "Database Stratum Password" \
"Enter your desired database stratum password.
\n\nYou may use the system generated password shown.
\n\nDesired Database Password:" \
$DEFAULT_StratumUserDBPassword \
StratumUserDBPassword
if [ -z "$StratumUserDBPassword" ]; then
# user hit ESC/cancel
exit
fi
fi
clear
dialog --title "Verify Your Responses" \
--yesno "Please verify your answers to continue setup:
Use Sub-Domain : ${UsingSubDomain}
Domain Name : ${DomainName}
Stratum URL : ${StratumURL}
Install SSL : ${InstallSSL}
System Email : ${SupportEmail}
Admin Location : ${AdminPanel}
Dedicated Coin Ports : ${CoinPort}
AutoExchange : ${AutoExchange}
Your Public IP : ${PublicIP}
DB Internal IP : ${DBInternalIP}
Web User : ${WebUser}
Web Password : ${WebPass}
WEB Internal IP : ${WebInternalIP}
Daemon User : ${DaemonUser}
Daemon Password : ${DaemonPass}
Daemon Internal IP : ${DaemonInternalIP}" 25 60
# Get exit status
# 0 means user hit [yes] button.
# 1 means user hit [no] button.
# 255 means user hit [Esc] key.
response=$?
case $response in
0)
#Generate random conf file name, random StratumDBUser and StratumDBPassword
# To increase security we are now randonly generating the yiimpfrontend DB name, panel, and stratum user names. So each installation is more secure.
# We do it here to save the variables in the global .yiimp.conf file
generate=$(openssl rand -base64 9 | tr -d "=+/")
YiiMPDBName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
StratumDBUser=Stratum$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
YiiMPPanelName=Panel$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
# Save the global options in $STORAGE_ROOT/yiimp/.yiimp.conf so that standalone
# tools know where to look for data.
echo 'STORAGE_USER='"${STORAGE_USER}"'
STORAGE_ROOT='"${STORAGE_ROOT}"'
PRIMARY_HOSTNAME='"${DomainName}"'
DomainName='"${DomainName}"'
UsingSubDomain='"${UsingSubDomain}"'
StratumURL='"${StratumURL}"'
InstallSSL='"${InstallSSL}"'
SupportEmail='"${SupportEmail}"'
AdminPanel='"${AdminPanel}"'
PublicIP='"${PublicIP}"'
CoinPort='"${CoinPort}"'
AutoExchange='"${AutoExchange}"'
DBInternalIP='"${DBInternalIP}"'
WebInternalIP='"${WebInternalIP}"'
DaemonInternalIP='"${DaemonInternalIP}"'
WebUser='"${WebUser}"'
WebPass='"'"''"${WebPass}"''"'"'
DaemonUser='"${DaemonUser}"'
DaemonPass='"'"''"${DaemonPass}"''"'"'
YiiMPDBName='"${YiiMPDBName}"'
DBRootPassword='"'"''"${DBRootPassword}"''"'"'
YiiMPPanelName='"${YiiMPPanelName}"'
PanelUserDBPassword='"'"''"${PanelUserDBPassword}"''"'"'
StratumDBUser='"${StratumDBUser}"'
StratumUserDBPassword='"'"''"${StratumUserDBPassword}"''"'"'
wireguard='"${wireguard}"'
# Unless you do some serious modifications this installer will not work with any other repo of yiimp!
YiiMPRepo='https://github.com/cryptopool-builders/yiimp.git'
' | sudo -E tee $STORAGE_ROOT/yiimp/.yiimp.conf >/dev/null 2>&1 ;;
1)
clear
bash $(basename $0) && exit;;
255)
clear
echo "User canceled installation"
exit 0
;;
esac
cd $HOME/multipool/yiimp_multi