forked from cryptopool-builders/multipool_yiimp_single
-
Notifications
You must be signed in to change notification settings - Fork 0
/
questions.sh
320 lines (275 loc) · 9.57 KB
/
questions.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
#!/usr/bin/env bash
#####################################################
# 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
source $HOME/multipool/yiimp_single/.wireguard.install.cnf
if [[ ("$wireguard" == "true") ]]; then
source $STORAGE_ROOT/yiimp/.wireguard.conf
fi
if [[ ("$wireguard" == "true") ]]; then
message_box "Ultimate Crypto-Server Setup Installer" \
"You have choosen to install YiiMP Single Server with WireGuard!
\n\nThis option will install all componets of YiiMP on a single server along with WireGuard so you can easily add additional servers in the future.
\n\nPlease make sure any domain name or sub domain names are pointed to this servers IP prior to running this installer.
\n\nAfter answering the following questions, setup will be automated.
\n\nNOTE: If installing on a system with less then 8 GB of RAM you may experience system issues!"
else
message_box "Ultimate Crypto-Server Setup Installer" \
"You have choosen to install YiiMP Single Server!
\n\nThis option will install all componets of YiiMP on a single server.
\n\nPlease make sure any domain name or sub domain names are pointed to this servers IP prior to running this installer.
\n\nAfter answering the following questions, setup will be automated.
\n\nNOTE: If installing on a system with less then 8 GB of RAM you may experience system issues!"
fi
# Begin user inputted responses for auto install
dialog --title "Using Domain Name" \
--yesno "Are you using a domain name? Example: example.com?
Make sure the DNS is updated!" 7 60
response=$?
case $response in
0) UsingDomain=yes;;
1) UsingDomain=no;;
255) echo "[ESC] key pressed.";;
esac
if [[ ("$UsingDomain" == "yes") ]]; then
dialog --title "Using Sub-Domain" \
--yesno "Are you using a sub-domain for the main website domain? Example pool.example.com?
Make sure the DNS is updated!" 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\nMake sure the domain is pointed to this server before continuing!
\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
else
# If user is not using a domain and is just using the server IP these fileds can be automatically detected.
# Sets server IP automatically
DomainName=$(get_publicip_from_web_service 4 || get_default_privateip 4)
StratumURL=$(get_publicip_from_web_service 4 || get_default_privateip 4)
UsingSubDomain=no
InstallSSL=no
fi
# Back to user input questions regardless of domain name or IP use
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
# These are all autgenerated but give user the oppertunity to set
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
# 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
YiiMPDBName=$(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 '')
StratumDBUser=Stratum$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
clear
dialog --title "Verify Your Responses" \
--yesno "Please verify your answers to continue setup:
Using Domain : ${UsingDomain}
Using 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}" 16 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)
# Save the global options in $STORAGE_ROOT/yiimp/.yiimp.conf so that standalone
# tools know where to look for data.
if [[ ("$wireguard" == "true") ]]; then
echo 'STORAGE_USER='"${STORAGE_USER}"'
STORAGE_ROOT='"${STORAGE_ROOT}"'
PRIMARY_HOSTNAME='"${DomainName}"'
UsingDomain='"${UsingDomain}"'
UsingSubDomain='"${UsingSubDomain}"'
DomainName='"${DomainName}"'
StratumURL='"${StratumURL}"'
InstallSSL='"${InstallSSL}"'
SupportEmail='"${SupportEmail}"'
AdminPanel='"${AdminPanel}"'
PublicIP='"${PublicIP}"'
CoinPort='"${CoinPort}"'
AutoExchange='"${AutoExchange}"'
DBInternalIP='"${DBInternalIP}"'
YiiMPDBName='"${YiiMPDBName}"'
DBRootPassword='"'"''"${DBRootPassword}"''"'"'
YiiMPPanelName='"${YiiMPPanelName}"'
PanelUserDBPassword='"'"''"${PanelUserDBPassword}"''"'"'
StratumDBUser='"${StratumDBUser}"'
StratumUserDBPassword='"'"''"${StratumUserDBPassword}"''"'"'
# Unless you do some serious modifications this installer will not work with any other repo of yiimp!
YiiMPRepo='https://github.com/Kudaraidee/yiimp.git'
' | sudo -E tee $STORAGE_ROOT/yiimp/.yiimp.conf >/dev/null 2>&1
else
echo 'STORAGE_USER='"${STORAGE_USER}"'
STORAGE_ROOT='"${STORAGE_ROOT}"'
PRIMARY_HOSTNAME='"${DomainName}"'
UsingDomain='"${UsingDomain}"'
UsingSubDomain='"${UsingSubDomain}"'
DomainName='"${DomainName}"'
StratumURL='"${StratumURL}"'
InstallSSL='"${InstallSSL}"'
SupportEmail='"${SupportEmail}"'
AdminPanel='"${AdminPanel}"'
PublicIP='"${PublicIP}"'
CoinPort='"${CoinPort}"'
AutoExchange='"${AutoExchange}"'
YiiMPDBName='"${YiiMPDBName}"'
DBRootPassword='"'"''"${DBRootPassword}"''"'"'
YiiMPPanelName='"${YiiMPPanelName}"'
PanelUserDBPassword='"'"''"${PanelUserDBPassword}"''"'"'
StratumDBUser='"${StratumDBUser}"'
StratumUserDBPassword='"'"''"${StratumUserDBPassword}"''"'"'
YiiMPStratumName='"${YiiMPStratumName}"'
# 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
fi;;
1)
clear
bash $(basename $0) && exit;;
255)
clear
echo "User canceled installation"
exit 0
;;
esac
cd $HOME/multipool/yiimp_single