forked from vaudois/yiimp_install_scrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
1375 lines (1141 loc) · 50.5 KB
/
install.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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
################################################################################
# Original Author: crombiecrunch
# Fork Author: manfromafar
# Fork Author: Vaudois
# Current Author: itsgudenuf
#
# Program:
# Install yiimp on Ubuntu 18.04 running Nginx, MariaDB, and php7.3
# v0.1
#
################################################################################
### Variable ###
githubyiimptpruvot=https://github.com/tpruvot/yiimp.git
githubrepoKudaraidee=https://github.com/Kudaraidee/yiimp.git
githubrepoAfinielTech=https://github.com/Afiniel-tech/yiimp.git
githubrepoAfiniel=https://github.com/afiniel/yiimp
output() {
printf "\E[0;33;40m"
echo $1
printf "\E[0m"
}
displayErr() {
echo
echo $1;
echo
exit 1;
}
YIIMP_INSTALLER_DIR=`pwd`
#Add user group sudo + no password
whoami=`whoami`
sudo usermod -aG sudo ${whoami}
echo '# yiimp
# It needs passwordless sudo functionality.
'""''"${whoami}"''""' ALL=(ALL) NOPASSWD:ALL
' | sudo -E tee /etc/sudoers.d/${whoami} >/dev/null 2>&1
echo "Loading.... Please standby"
# install some basic things needed to even start
sudo apt update -y >/dev/null 2>&1
sudo apt install dialog curl software-properties-common -y >/dev/null 2>&1
#Copy needed files
sudo cp -r conf/functions.sh /etc/functions.sh
sudo cp -r conf/screen-scrypt.sh /etc/
sudo cp -r conf/editconf.py /usr/bin/
cp -r utils/addport $HOME/bin/addport
chmod +x $HOME/bin/addport
sudo chmod +x /usr/bin/editconf.py
sudo chmod +x /etc/screen-scrypt.sh
sudo chmod 644 /etc/functions.sh
source /etc/functions.sh
source utils/packagecompil.sh
clear
term_art
source conf/prerequisite.sh
sleep 3
source conf/getip.sh
echo 'PUBLIC_IP='"${PUBLIC_IP}"'
PUBLIC_IPV6='"${PUBLIC_IPV6}"'
DISTRO='"${DISTRO}"'
PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee conf/pool.conf >/dev/null 2>&1
echo
echo
echo -e "$RED Make sure you double check before hitting enter! Only one shot at these! $COL_RESET"
echo
#read -e -p "Enter time zone (e.g. America/New_York) : " TIME
read -e -p "Domain Name (no http:// or www. just : example.com or 185.22.24.26) : " server_name
read -e -p "Enter subdomain for stratum connections on miners (usa.example.com?) [y/N] : " sub_domain
read -e -p "Enter support email (e.g. [email protected]) : " EMAIL
read -e -p "Set Pool to AutoExchange? i.e. mine any coin with BTC address? [y/N] : " BTC
read -e -p "Please enter a new location for /site/adminRights this is to customize the Admin Panel entrance url (e.g. myAdminpanel) : " admin_panel
read -e -p "Enter the Public IP of the system you will use to access the admin panel (http://www.whatsmyip.org/) : " Public
read -e -p "Enter desired Yiimp GitHub (1=Kudaraidee or 2=tpruvot or 3=Afiniel-Tech 4= Afiniel) [1 by default] : " yiimpver
read -e -p "Install Fail2ban? [y/N] : " install_fail2ban
read -e -p "Install UFW and configure ports? [y/N] : " UFW
read -e -p "Install Wireguard for future remote stratums??? [y/N]: " wg_install
if [[ ("$wg_install" == "y" || "$wg_install" == "Y") ]]; then
read -e -p "Enter a Local Wireguard Private IP for this server (x.x.x.x): " wg_ip
fi
echo -e "\n\n\n\n"
echo -e "$RED You entered the following. If it's wrong CTRL-C now to start over $COL_RESET"
echo "Domain Name: $server_name"
echo "Stratum Subdomain: $sub_domain"
echo "Support Email: $EMAIL"
echo "AutoExchange: $BTC"
echo "Panel Url: $admin_panel"
echo "IP Range for Admin: $Public"
echo "Yiimb Github choice: $yiimpver"
echo "Install Fail2ban: $install_fail2ban"
echo "Install UFW: $UFW"
echo "Install wiregauard: $wg_install"
echo "Wireguard wg0 IP: $wg_ip"
read -e -p "Press ENTER to continue or CTRL-C to exit and start over" dummy
echo -e "\n\n\n\n"
# Update package and Upgrade Ubuntu
echo
echo
echo -e "$CYAN => Updating system and installing required packages :$COL_RESET"
echo
sleep 3
hide_output sudo apt -y update
hide_output sudo apt -y upgrade
hide_output sudo apt -y autoremove
apt_install dialog python3 python3-pip acl nano apt-transport-https figlet htop
echo -e "$GREEN Done...$COL_RESET"
# Switch Aptitude
echo
echo -e "$CYAN Switching to Aptitude $COL_RESET"
echo
sleep 3
apt_install aptitude
echo -e "$GREEN Done...$COL_RESET $COL_RESET"
# Installing Nginx
echo
echo
echo -e "$CYAN => Installing Nginx server : $COL_RESET"
echo
sleep 3
if [ -f /usr/sbin/apache2 ]; then
echo -e "Removing apache..."
hide_output apt-get -y purge apache2 apache2-*
hide_output apt-get -y --purge autoremove
fi
apt_install nginx
hide_output sudo rm /etc/nginx/sites-enabled/default
hide_output sudo systemctl start nginx.service
hide_output sudo systemctl enable nginx.service
hide_output sudo systemctl start cron.service
hide_output sudo systemctl enable cron.service
sudo systemctl status nginx | sed -n "1,3p"
echo
echo -e "$GREEN Done...$COL_RESET"
# Making Nginx a bit hard
echo 'map $http_user_agent $blockedagent {
default 0;
~*malicious 1;
~*bot 1;
~*backdoor 1;
~*crawler 1;
~*bandit 1;
}
' | sudo -E tee /etc/nginx/blockuseragents.rules >/dev/null 2>&1
# Installing Mariadb
echo
echo
echo -e "$CYAN => Installing Mariadb Server : $COL_RESET"
echo
echo -e "...Installing MariaDB Repository...$COL_RESET"
if [[ ("$DISTRO" == "16") ]]; then
sudo apt-get install software-properties-common dirmngr apt-transport-https
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb https://atl.mirrors.knownhost.com/mariadb/repo/10.4/ubuntu xenial main'
elif [[ ("$DISTRO" == "18") ]]; then
sudo apt-get install apt-transport-https curl
sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo sh -c "echo 'deb https://atl.mirrors.knownhost.com/mariadb/repo/10.4/ubuntu bionic main' >> /etc/apt/sources.list.d/mariadb.list"
elif [[ ("$DISTRO" == "20") ]]; then
sudo apt-get install apt-transport-https curl
sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo sh -c "echo 'deb https://atl.mirrors.knownhost.com/mariadb/repo/10.4/ubuntu focal main' >> /etc/apt/sources.list.d/mariadb.list"
elif [[ ("$DISTRO" == "22") ]]; then
sudo apt-get install apt-transport-https curl
sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo sh -c "echo 'deb https://atl.mirrors.knownhost.com/mariadb/repo/10.4/ubuntu jammy main' >> /etc/apt/sources.list.d/mariadb.list"
else
echo -e "$RED Ooooops!!! We have an unknown DISTRO. How did this happen???$COL_RESET"
echo -e "$RED ... hope you made a snapshot before starting... this install is ABORTED!!!!$COL_RESET"
exit
fi
hide_output sudo apt update
hide_output sudo apt -y upgrade
hide_output sudo apt autoremove -y
sleep 3
# Create random password
rootpasswd=$(openssl rand -base64 12)
export DEBIAN_FRONTEND="noninteractive"
apt_install mariadb-server
# fix mysql for remote sessions
sed -i 's/bind-address*/bind-address = 0.0.0.0/g' /etc/mysql/my.cnf
hide_output sudo systemctl start mysql
hide_output sudo systemctl enable mysql
sudo systemctl status mysql | sed -n "1,3p"
echo
echo -e "$GREEN Done...$COL_RESET"
# Installing Installing php7.3
echo
echo
echo -e "$CYAN => Installing php7.3 : $COL_RESET"
echo
sleep 3
source conf/pool.conf
hide_output sudo add-apt-repository ppa:ondrej/php -y
hide_output sudo apt -y update
# 22.04 & 20.04 are missing php-gettext
# need to solve this before we can add support for those distros
PACKAGES='
php7.3
php7.3-cgi
php7.3-cli
php7.3-common
php7.3-curl
php7.3-fpm
php7.3-gd
php7.3-imap
php7.3-intl
php7.3-mbstring
php7.3-memcache
php7.3-mysql
php7.3-opcache
php7.3-pspell
php7.3-recode
php7.3-sqlite3
php7.3-tidy
php7.3-xmlrpc
php7.3-xsl
php7.3-zip
php-pear
imagemagick
php-imagick
libruby
mcrypt
memcached
php-memcache
php-gettext
libpsl-dev
libnghttp2-dev
certbot
python3-certbot-dns-cloudflare
python3-certbot-nginx
patch
'
sudo apt install -y $PACKAGES
sleep 5
hide_output sudo systemctl start php7.3-fpm
hide_output sudo systemctl status php7.3-fpm | sed -n "1,3p"
# Set default php to 7.3
sudo update-alternatives --set php /usr/bin/php7.3
echo
echo -e "$GREEN Done...$COL_RESET"
# Installing other needed files
echo
echo
echo -e "$CYAN => Installing other needed files : $COL_RESET"
echo
sleep 3
sudo apt install -y libgmp3-dev libmysqlclient-dev libcurl4-gnutls-dev libkrb5-dev libldap2-dev libidn11-dev gnutls-dev \
librtmp-dev postfix mutt screen git
apt_install pwgen -y
echo -e "$GREEN Done...$COL_RESET"
sleep 3
# Installing Package to compile crypto currency
echo
echo
echo -e "$CYAN => Installing Package to compile crypto currencies $COL_RESET"
echo
cd ${YIIMP_INSTALLER_DIR}
package_compile_crypto
sleep 3
cd ${YIIMP_INSTALLER_DIR}
package_compile_coin
sleep 3
cd ${YIIMP_INSTALLER_DIR}
package_daemonbuilder
echo '
#!/usr/bin/env bash
source /etc/functions.sh # load our functions
cd $HOME/utils/daemon_builder
bash start.sh
cd ~
' | sudo -E tee /usr/bin/daemonbuilder >/dev/null 2>&1
sudo chmod +x /usr/bin/daemonbuilder
echo
echo -e "$GREEN Done...$COL_RESET"
# Generating Random Passwords
panelpass=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
stratumpass=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
phpmyadmin_pass=`pwgen -c -1 20`
# Test Email
# todo = root_email and send_email are not set anywhere
# echo
# echo
# echo -e "$CYAN => Testing to see if server emails are sent $COL_RESET"
# echo
# sleep 3
# if [[ "$root_email" != "" ]]; then
# echo $root_email > sudo tee --append ~/.email
# echo $root_email > sudo tee --append ~/.forward
# if [[ ("$send_email" == "y" || "$send_email" == "Y" || "$send_email" == "") ]]; then
# echo "This is a mail test for the SMTP Service." > sudo tee --append /tmp/email.message
# echo "You should receive this !" >> sudo tee --append /tmp/email.message
# echo "" >> sudo tee --append /tmp/email.message
# echo "Cheers" >> sudo tee --append /tmp/email.message
# sudo sendmail -s "SMTP Testing" $root_email < sudo tee --append /tmp/email.message
# sudo rm -f /tmp/email.message
# echo "Mail sent"
# fi
# fi
# echo -e "$GREEN Done...$COL_RESET"
# Installing Fail2Ban & UFW
echo
echo
echo -e "$CYAN => Some optional installs (Fail2Ban & UFW) $COL_RESET"
echo
sleep 3
if [[ ("$install_fail2ban" == "y" || "$install_fail2ban" == "Y" ) ]]; then
apt_install fail2ban
sudo systemctl status fail2ban | sed -n "1,3p"
fi
if [[ ("$UFW" == "y" || "$UFW" == "Y") ]]; then
apt_install ufw
hide_output sudo ufw default deny incoming
hide_output sudo ufw default allow outgoing
hide_output sudo ufw allow ssh
hide_output sudo ufw allow http
hide_output sudo ufw allow https
hide_output sudo ufw --force enable
sudo systemctl status ufw | sed -n "1,3p"
fi
echo
echo -e "$GREEN Done...$COL_RESET"
# Installing PhpMyAdmin
echo
echo
echo -e "$CYAN => Installing phpMyAdmin $COL_RESET"
echo
sleep 3
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-user string root" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password $rootpasswd" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password $phpmyadmin_pass" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password $phpmyadmin_pass" | sudo debconf-set-selections
apt_install phpmyadmin
# Patch the sql.lib.php for this error
# https://tecadmin.net/warning-in-libraries-sql-lib-php-613-count-parameter-must-be-an-array-or-an-object-that-implements-countable/
sudo patch -u -b /usr/share/phpmyadmin/libraries/sql.lib.php -i $YIIMP_INSTALLER_DIR/patches/phpmyadmin-sql-lib.patch
echo -e "$GREEN Done...$COL_RESET"
# Installing Yiimp
echo
echo
echo -e "$CYAN => Installing Yiimp $COL_RESET"
echo
echo -e "Grabbing yiimp front Github, building files and setting file structure."
echo
sleep 3
# Generating Random Password for stratum
blckntifypass=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
# Compil Blocknotify
cd ~
if [[ ("$yiimpver" == "1" || "$yiimpver" == "") ]];then
cd ~
hide_output git clone $githubrepoKudaraidee
elif [[ "$yiimpver" == "2" ]]; then
cd ~
hide_output git clone $githubyiimptpruvot
cd ~
elif [[ "$yiimpver" == "3" ]]; then
cd ~
hide_output git clone $githubrepoAfinielTech
elif [[ "$yiimpver" == "3" ]]; then
cd ~
hide_output git clone $githubrepoAfiniel -b next
fi
cd $HOME/yiimp/blocknotify
sudo sed -i 's/tu8tu5/'$blckntifypass'/' blocknotify.cpp
hide_output sudo make
# Compil iniparser
cd $HOME/yiimp/stratum/iniparser
hide_output sudo make
# Compil Stratum
cd $HOME/yiimp/stratum
if [[ ("$BTC" == "y" || "$BTC" == "Y") ]]; then
sudo sed -i 's/CFLAGS += -DNO_EXCHANGE/#CFLAGS += -DNO_EXCHANGE/' $HOME/yiimp/stratum/Makefile
fi
hide_output sudo make
# Copy Files (Blocknotify,iniparser,Stratum)
cd $HOME/yiimp
if [[ ("$yiimpver" == "1" || "$yiimpver" == "" || "$yiimpver" == "4") ]];then
sudo sed -i 's/myadmin/'$admin_panel'/' $HOME/yiimp/web/yaamp/modules/site/SiteController.php
else
sudo sed -i 's/AdminRights/'$admin_panel'/' $HOME/yiimp/web/yaamp/modules/site/SiteController.php
fi
sudo cp -r $HOME/yiimp/web /var/
sudo mkdir -p /var/stratum
cd $HOME/yiimp/stratum
sudo cp -a config.sample/. /var/stratum/config
sudo cp -r stratum /var/stratum
sudo cp -r run.sh /var/stratum
cd $HOME/yiimp
sudo cp -r $HOME/yiimp/bin/. /bin/
sudo cp -r $HOME/yiimp/blocknotify/blocknotify /usr/bin/
sudo cp -r $HOME/yiimp/blocknotify/blocknotify /var/stratum/
sudo mkdir -p /etc/yiimp
sudo mkdir -p /$HOME/backup/
#fixing yiimp
sudo sed -i "s|ROOTDIR=/data/yiimp|ROOTDIR=/var|g" /bin/yiimp
#fixing run.sh
sudo rm -r /var/stratum/config/run.sh
echo '
#!/bin/bash
ulimit -n 10240
ulimit -u 10240
cd /var/stratum
while true; do
./stratum /var/stratum/config/$1
sleep 2
done
exec bash
' | sudo -E tee /var/stratum/config/run.sh >/dev/null 2>&1
sudo chmod +x /var/stratum/config/run.sh
echo -e "$GREEN Done...$COL_RESET"
# Update Timezone
echo
echo
echo -e "$CYAN => Update default timezone. $COL_RESET"
echo
# Check if link file
#sudo [ -L /etc/localtime ] && sudo unlink /etc/localtime
# Update time zone
#sudo ln -sf /usr/share/zoneinfo/$TIME /etc/localtime
#apt_install ntpdate
# Write time to clock.
#sudo hwclock -w
#echo -e "$GREEN Done...$COL_RESET"
echo -e " Setting TimeZone to UTC...$COL_RESET"
if [ ! -f /etc/timezone ]; then
echo "Setting timezone to UTC."
echo "Etc/UTC" > sudo /etc/timezone
sudo systemctl restart rsyslog
fi
sudo systemctl status rsyslog | sed -n "1,3p"
echo
echo -e "$GREEN Done...$COL_RESET"
# Making Web Server Magic Happen
#echo
#echo -e "$CYAN Making Web Server Magic Happen! $COL_RESET"
#echo
# Adding user to group, creating dir structure, setting permissions
#sudo mkdir -p /var/www/$server_name/html
# Creating webserver initial config file
echo
echo
echo -e "$CYAN => Creating webserver initial config file $COL_RESET"
echo
# Adding user to group, creating dir structure, setting permissions
sudo mkdir -p /var/www/$server_name/html
if [[ ("$sub_domain" == "y" || "$sub_domain" == "Y") ]]; then
echo 'include /etc/nginx/blockuseragents.rules;
server {
if ($blockedagent) {
return 403;
}
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 444;
}
listen 80;
listen [::]:80;
server_name '"${server_name}"';
root "/var/www/'"${server_name}"'/html/web";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$args;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?r=$1;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/'"${server_name}"'.app-access.log;
error_log /var/log/nginx/'"${server_name}"'.app-error.log;
# allow larger file uploads and longer script runtimes
client_body_buffer_size 50k;
client_header_buffer_size 50k;
client_max_body_size 50k;
large_client_header_buffers 2 50k;
sendfile off;
location ~ ^/index\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
return 404;
}
location ~ \.sh {
return 404;
}
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
location /phpmyadmin {
root /usr/share/;
index index.php;
try_files $uri $uri/ =404;
location ~ ^/phpmyadmin/(doc|sql|setup)/ {
deny all;
}
location ~ /phpmyadmin/(.+\.php)$ {
allow '"${Public}"';
deny all;
client_max_body_size 2M;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}
}
' | sudo -E tee /etc/nginx/sites-available/$server_name.conf >/dev/null 2>&1
sudo ln -s /etc/nginx/sites-available/$server_name.conf /etc/nginx/sites-enabled/$server_name.conf
sudo ln -s /var/web /var/www/$server_name/html
hide_output sudo systemctl reload php7.3-fpm.service
hide_output sudo systemctl restart nginx.service
echo -e "$GREEN Done...$COL_RESET"
else
echo 'include /etc/nginx/blockuseragents.rules;
server {
if ($blockedagent) {
return 403;
}
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 444;
}
listen 80;
listen [::]:80;
server_name '"${server_name}"' www.'"${server_name}"';
root "/var/www/'"${server_name}"'/html/web";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$args;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?r=$1;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/'"${server_name}"'.app-access.log;
error_log /var/log/nginx/'"${server_name}"'.app-error.log;
# allow larger file uploads and longer script runtimes
client_body_buffer_size 50k;
client_header_buffer_size 50k;
client_max_body_size 50k;
large_client_header_buffers 2 50k;
sendfile off;
location ~ ^/index\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
return 404;
}
location ~ \.sh {
return 404;
}
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
location /phpmyadmin {
root /usr/share/;
index index.php;
try_files $uri $uri/ =404;
location ~ ^/phpmyadmin/(doc|sql|setup)/ {
deny all;
}
location ~ /phpmyadmin/(.+\.php)$ {
allow '"${Public}"';
deny all;
client_max_body_size 2M;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}
}
' | sudo -E tee /etc/nginx/sites-available/$server_name.conf >/dev/null 2>&1
sudo ln -s /etc/nginx/sites-available/$server_name.conf /etc/nginx/sites-enabled/$server_name.conf
sudo ln -s /var/web /var/www/$server_name/html
hide_output sudo systemctl reload php7.3-fpm.service
hide_output sudo systemctl restart nginx.service
fi
# Config Database
echo
echo
echo -e "$CYAN => Now for the database fun! $COL_RESET"
echo
sleep 3
# Create database
Q1="CREATE DATABASE IF NOT EXISTS yiimpfrontend;"
Q2="GRANT ALL ON *.* TO 'panel'@'localhost' IDENTIFIED BY '$panelpass';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
sudo mysql -u root -p="" -e "$SQL"
# Create stratum user
Q1="GRANT ALL ON *.* TO 'stratum'@'localhost' IDENTIFIED BY '$stratumpass';"
Q2="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}"
sudo mysql -u root -p="" -e "$SQL"
#Create my.cnf
echo '
[clienthost1]
user=panel
password='"${panelpass}"'
database=yiimpfrontend
host=localhost
[clienthost2]
user=stratum
password='"${stratumpass}"'
database=yiimpfrontend
host=localhost
[myphpadmin]
user=phpmyadmin
password='"${phpmyadmin_pass}"'
[mysql]
user=root
password='"${rootpasswd}"'
' | sudo -E tee ~/.my.cnf >/dev/null 2>&1
sudo chmod 0600 ~/.my.cnf
# Create keys file
echo '
<?php
/* Sample config file to put in /etc/yiimp/keys.php */
define('"'"'YIIMP_MYSQLDUMP_USER'"'"', '"'"'panel'"'"');
define('"'"'YIIMP_MYSQLDUMP_PASS'"'"', '"'"''"${panelpass}"''"'"');
/* Keys required to create/cancel orders and access your balances/deposit addresses */
define('"'"'EXCH_ALCUREX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_ALTILLY_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_BIBOX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_BINANCE_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_BITTREX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_BITSTAMP_SECRET'"'"','"'"''"'"');
define('"'"'EXCH_BLEUTRADE_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_BTER_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_CEXIO_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_CREX24_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_CCEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_COINMARKETS_PASS'"'"', '"'"''"'"');
define('"'"'EXCH_CRYPTOHUB_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_CRYPTOWATCH_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_DELIONDEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_EMPOEX_SECKEY'"'"', '"'"''"'"');
define('"'"'EXCH_ESCODEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_GATEIO_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_GRAVIEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_HITBTC_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_JUBI_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_KRAKEN_SECRET'"'"','"'"''"'"');
define('"'"'EXCH_KUCOIN_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_LIVECOIN_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_POLONIEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_SHAPESHIFT_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_STOCKSEXCHANGE_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_SWIFTEX_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_TRADEOGRE_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_YOBIT_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_CRYPTOPIA_SECRET'"'"', '"'"''"'"');
define('"'"'EXCH_NOVA_SECRET'"'"','"'"''"'"');
' | sudo -E tee /etc/yiimp/keys.php >/dev/null 2>&1
echo -e "$GREEN Done...$COL_RESET"
# Peforming the SQL import
echo
echo
echo -e "$CYAN => Database 'yiimpfrontend' and users 'panel' and 'stratum' created with password $panelpass and $stratumpass, will be saved for you $COL_RESET"
echo
echo -e "Performing the SQL import"
echo
sleep 3
cd ~
cd yiimp/sql
if [[ ("$yiimpver" == "1" || "$yiimpver" == "") ]];then
# Kudaraidee Sql
# Import sql dump
# sudo zcat 2021-06-21-yaamp.sql.gz | sudo mysql
# fix for the .gz file that is really a rar file
apt_install unrar
unrar e 2021-06-21-yaamp.sql.gz
echo -e "\t\t importing.... 2021-06-21-yaamp.sql"
cat 2021-06-21-yaamp.sql | sudo mysql yiimpfrontend
# Oh the humanity!
echo -e "\t\t importing.... 2015-07-01-accounts_hostaddr.sql"
sudo mysql yiimpfrontend --force < 2015-07-01-accounts_hostaddr.sql
echo -e "\t\t importing.... 2015-07-15-coins_hasmasternodes.sql"
sudo mysql yiimpfrontend --force < 2015-07-15-coins_hasmasternodes.sql
echo -e "\t\t importing.... 2015-09-20-blocks_worker.sql"
sudo mysql yiimpfrontend --force < 2015-09-20-blocks_worker.sql
echo -e "\t\t importing.... 2016-02-17-payouts_errmsg.sql"
sudo mysql yiimpfrontend --force < 2016-02-17-payouts_errmsg.sql
echo -e "\t\t importing.... 2016-02-18-accounts_donation.sql"
sudo mysql yiimpfrontend --force < 2016-02-18-accounts_donation.sql
echo -e "\t\t importing.... 2016-02-23-shares_diff.sql"
sudo mysql yiimpfrontend --force < 2016-02-23-shares_diff.sql
echo -e "\t\t importing.... 2016-03-26-markets.sql"
sudo mysql yiimpfrontend --force < 2016-03-26-markets.sql
echo -e "\t\t importing.... 2016-03-30-coins.sql"
sudo mysql yiimpfrontend --force < 2016-03-30-coins.sql
echo -e "\t\t importing.... 2016-04-03-accounts.sql"
sudo mysql yiimpfrontend --force < 2016-04-03-accounts.sql
echo -e "\t\t importing.... 2016-04-24-market_history.sql"
sudo mysql yiimpfrontend --force < 2016-04-24-market_history.sql
echo -e "\t\t importing.... 2016-04-27-settings.sql"
sudo mysql yiimpfrontend --force < 2016-04-27-settings.sql
echo -e "\t\t importing.... 2016-05-11-coins.sql"
sudo mysql yiimpfrontend --force < 2016-05-11-coins.sql
echo -e "\t\t importing.... 2016-05-15-benchmarks.sql"
sudo mysql yiimpfrontend --force < 2016-05-15-benchmarks.sql
echo -e "\t\t importing.... 2016-05-23-bookmarks.sql"
sudo mysql yiimpfrontend --force < 2016-05-23-bookmarks.sql
echo -e "\t\t importing.... 2016-06-01-notifications.sql"
sudo mysql yiimpfrontend --force < 2016-06-01-notifications.sql
echo -e "\t\t importing.... 2016-06-04-bench_chips.sql"
sudo mysql yiimpfrontend --force < 2016-06-04-bench_chips.sql
echo -e "\t\t importing.... 2016-11-23-coins.sql"
sudo mysql yiimpfrontend --force < 2016-11-23-coins.sql
echo -e "\t\t importing.... 2017-02-05-benchmarks.sql"
sudo mysql yiimpfrontend --force < 2017-02-05-benchmarks.sql
echo -e "\t\t importing.... 2017-03-31-earnings_index.sql"
sudo mysql yiimpfrontend --force < 2017-03-31-earnings_index.sql
echo -e "\t\t importing.... 2017-05-accounts_case_swaptime.sql"
sudo mysql yiimpfrontend --force < 2017-05-accounts_case_swaptime.sql
echo -e "\t\t importing.... 2017-06-payouts_coinid_memo.sql"
sudo mysql yiimpfrontend --force < 2017-06-payouts_coinid_memo.sql
echo -e "\t\t importing.... 2017-09-notifications.sql"
sudo mysql yiimpfrontend --force < 2017-09-notifications.sql
echo -e "\t\t importing.... 2017-10-bookmarks.sql"
sudo mysql yiimpfrontend --force < 2017-10-bookmarks.sql
echo -e "\t\t importing.... 2017-11-segwit.sql"
sudo mysql yiimpfrontend --force < 2017-11-segwit.sql
echo -e "\t\t importing.... 2018-01-stratums_ports.sql"
sudo mysql yiimpfrontend --force < 2018-01-stratums_ports.sql
echo -e "\t\t importing.... 2018-02-coins_getinfo.sql"
sudo mysql yiimpfrontend --force < 2018-02-coins_getinfo.sql
echo -e "\t\t importing.... 2018-09-22-workers.sql"
sudo mysql yiimpfrontend --force < 2018-09-22-workers.sql
echo -e "\t\t importing.... 2019-03-coins_thepool_life.sql"
sudo mysql yiimpfrontend --force < 2019-03-coins_thepool_life.sql
echo -e "\t\t importing.... 2020-06-03-blocks.sql"
sudo mysql yiimpfrontend --force < 2020-06-03-blocks.sql
elif [[ "$yiimpver" == "2" ]]; then
# Tpruvot Sql
# Import sql dump
sudo zcat 2016-04-03-yaamp.sql.gz | sudo mysql yiimpfrontend
# Oh the humanity!
sudo mysql yiimpfrontend --force < 2015-07-01-accounts_hostaddr.sql
sudo mysql yiimpfrontend --force < 2015-07-15-coins_hasmasternodes.sql
sudo mysql yiimpfrontend --force < 2015-09-20-blocks_worker.sql
sudo mysql yiimpfrontend --force < 2016-02-17-payouts_errmsg.sql
sudo mysql yiimpfrontend --force < 2016-02-18-accounts_donation.sql
sudo mysql yiimpfrontend --force < 2016-02-23-shares_diff.sql
sudo mysql yiimpfrontend --force < 2016-03-26-markets.sql
sudo mysql yiimpfrontend --force < 2016-03-30-coins.sql
sudo mysql yiimpfrontend --force < 2016-04-03-accounts.sql
sudo mysql yiimpfrontend --force < 2016-04-24-market_history.sql
sudo mysql yiimpfrontend --force < 2016-04-27-settings.sql
sudo mysql yiimpfrontend --force < 2016-05-11-coins.sql
sudo mysql yiimpfrontend --force < 2016-05-15-benchmarks.sql
sudo mysql yiimpfrontend --force < 2016-05-23-bookmarks.sql
sudo mysql yiimpfrontend --force < 2016-06-01-notifications.sql
sudo mysql yiimpfrontend --force < 2016-06-04-bench_chips.sql
sudo mysql yiimpfrontend --force < 2016-11-23-coins.sql
sudo mysql yiimpfrontend --force < 2017-02-05-benchmarks.sql
sudo mysql yiimpfrontend --force < 2017-03-31-earnings_index.sql
sudo mysql yiimpfrontend --force < 2017-05-accounts_case_swaptime.sql
sudo mysql yiimpfrontend --force < 2017-06-payouts_coinid_memo.sql
sudo mysql yiimpfrontend --force < 2017-09-notifications.sql
sudo mysql yiimpfrontend --force < 2017-10-bookmarks.sql
sudo mysql yiimpfrontend --force < 2017-11-segwit.sql
sudo mysql yiimpfrontend --force < 2018-01-stratums_ports.sql
sudo mysql yiimpfrontend --force < 2018-02-coins_getinfo.sql
elif [[ "$yiimpver" == "3" ]]; then
# Afiniel Tech Sql
# Import sql dump
sudo zcat 2016-04-03-yaamp.sql.gz | sudo mysql yiimpfrontend
# Oh the humanity!
sudo mysql yiimpfrontend --force < 2015-07-01-accounts_hostaddr.sql
sudo mysql yiimpfrontend --force < 2015-07-15-coins_hasmasternodes.sql
sudo mysql yiimpfrontend --force < 2015-09-20-blocks_worker.sql
sudo mysql yiimpfrontend --force < 2016-02-17-payouts_errmsg.sql
sudo mysql yiimpfrontend --force < 2016-02-18-accounts_donation.sql
sudo mysql yiimpfrontend --force < 2016-02-23-shares_diff.sql
sudo mysql yiimpfrontend --force < 2016-03-26-markets.sql
sudo mysql yiimpfrontend --force < 2016-03-30-coins.sql
sudo mysql yiimpfrontend --force < 2016-04-03-accounts.sql
sudo mysql yiimpfrontend --force < 2016-04-24-market_history.sql
sudo mysql yiimpfrontend --force < 2016-04-27-settings.sql
sudo mysql yiimpfrontend --force < 2016-05-11-coins.sql
sudo mysql yiimpfrontend --force < 2016-05-15-benchmarks.sql
sudo mysql yiimpfrontend --force < 2016-05-23-bookmarks.sql
sudo mysql yiimpfrontend --force < 2016-06-01-notifications.sql
sudo mysql yiimpfrontend --force < 2016-06-04-bench_chips.sql
sudo mysql yiimpfrontend --force < 2016-11-23-coins.sql
sudo mysql yiimpfrontend --force < 2017-02-05-benchmarks.sql
sudo mysql yiimpfrontend --force < 2017-03-31-earnings_index.sql
sudo mysql yiimpfrontend --force < 2017-05-accounts_case_swaptime.sql
sudo mysql yiimpfrontend --force < 2017-06-payouts_coinid_memo.sql
sudo mysql yiimpfrontend --force < 2017-09-notifications.sql
sudo mysql yiimpfrontend --force < 2017-10-bookmarks.sql
sudo mysql yiimpfrontend --force < 2017-11-segwit.sql
sudo mysql yiimpfrontend --force < 2018-01-stratums_ports.sql
sudo mysql yiimpfrontend --force < 2018-02-coins_getinfo.sql
sudo mysql yiimpfrontend --force < 2018-09-22-workers.sql
sudo mysql yiimpfrontend --force < 2019-03-coins_thepool_life.sql
sudo mysql yiimpfrontend --force < 2019-11-10-yiimp.sql.gz
sudo mysql yiimpfrontend --force < 2020-06-03-blocks.sql
elif [[ "$yiimpver" == "4" ]]; then
# Afiniel
# Import sql dump
sudo zcat 2021-06-21-yaamp.sql.gz | sudo mysql yiimpfrontend
# Oh the humanity!
sudo mysql yiimpfrontend --force < 2015-07-01-accounts_hostaddr.sql
sudo mysql yiimpfrontend --force < 2015-07-15-coins_hasmasternodes.sql
sudo mysql yiimpfrontend --force < 2015-09-20-blocks_worker.sql
sudo mysql yiimpfrontend --force < 2016-02-17-payouts_errmsg.sql
sudo mysql yiimpfrontend --force < 2016-02-18-accounts_donation.sql
sudo mysql yiimpfrontend --force < 2016-02-23-shares_diff.sql
sudo mysql yiimpfrontend --force < 2016-03-26-markets.sql
sudo mysql yiimpfrontend --force < 2016-03-30-coins.sql
sudo mysql yiimpfrontend --force < 2016-04-03-accounts.sql
sudo mysql yiimpfrontend --force < 2016-04-24-market_history.sql
sudo mysql yiimpfrontend --force < 2016-04-27-settings.sql
sudo mysql yiimpfrontend --force < 2016-05-11-coins.sql
sudo mysql yiimpfrontend --force < 2016-05-15-benchmarks.sql
sudo mysql yiimpfrontend --force < 2016-05-23-bookmarks.sql