diff --git a/db.sh b/db.sh index fcb2166..be6824f 100644 --- a/db.sh +++ b/db.sh @@ -4,6 +4,8 @@ source /etc/functions.sh source $STORAGE_ROOT/yiimp/.yiimp.conf +source $HOME/multipool/yiimp_single/.wireguard.install.cnf +source $STORAGE_ROOT/yiimp/.wireguard.conf echo Installing MariaDB... MARIADB_VERSION='10.3' @@ -12,14 +14,29 @@ sudo debconf-set-selections <<< "maria-db-$MARIADB_VERSION mysql-server/root_pas apt_install mariadb-server mariadb-client echo Creating DB users for YiiMP... + +if [[ ("$wireguard" == "false") ]]; then + Q1="CREATE DATABASE IF NOT EXISTS yiimpfrontend;" -Q2="GRANT ALL ON *.* TO 'panel'@'localhost' IDENTIFIED BY '$PanelUserDBPassword';" -Q3="GRANT ALL ON *.* TO 'stratum'@'localhost' IDENTIFIED BY '$StratumUserDBPassword';" +Q2="GRANT ALL ON yiimpfrontend.* TO 'panel'@'localhost' IDENTIFIED BY '$PanelUserDBPassword';" +Q3="GRANT ALL ON yiimpfrontend.* TO 'stratum'@'localhost' IDENTIFIED BY '$StratumUserDBPassword';" Q4="FLUSH PRIVILEGES;" SQL="${Q1}${Q2}${Q3}${Q4}" sudo mysql -u root -p"${DBRootPassword}" -e "$SQL" +else + Q1="CREATE DATABASE IF NOT EXISTS yiimpfrontend;" + Q2="GRANT ALL ON yiimpfrontend.* TO 'panel'@'${DBInternalIP}' IDENTIFIED BY '$PanelUserDBPassword';" + Q3="GRANT ALL ON yiimpfrontend.* TO 'stratum'@'${DBInternalIP}' IDENTIFIED BY '$StratumUserDBPassword';" + Q4="FLUSH PRIVILEGES;" + SQL="${Q1}${Q2}${Q3}${Q4}" + sudo mysql -u root -p"${DBRootPassword}" -e "$SQL" +fi + echo Creating my.cnf... + +if [[ ("$wireguard" == "false") ]]; then + echo '[clienthost1] user=panel password='"${PanelUserDBPassword}"' @@ -35,6 +52,23 @@ user=root password='"${DBRootPassword}"' ' | sudo -E tee $STORAGE_ROOT/yiimp/.my.cnf >/dev/null 2>&1 +else + + echo '[clienthost1] + user=panel + password='"${PanelUserDBPassword}"' + database=yiimpfrontend + host='"${DBInternalIP}"' + [clienthost2] + user=stratum + password='"${StratumUserDBPassword}"' + database=yiimpfrontend + host='"${DBInternalIP}"' + [mysql] + user=root + password='"${DBRootPassword}"' + ' | sudo -E tee $STORAGE_ROOT/yiimp/.my.cnf >/dev/null 2>&1 + sudo chmod 0600 $STORAGE_ROOT/yiimp/.my.cnf echo Passwords can be found in $STORAGE_ROOT/yiimp/.my.cnf @@ -62,6 +96,8 @@ sudo mysql -u root -p"${DBRootPassword}" yiimpfrontend --force < 2018-01-stratum sudo mysql -u root -p"${DBRootPassword}" yiimpfrontend --force < 2018-02-coins_getinfo.sql sudo mysql -u root -p"${DBRootPassword}" yiimpfrontend --force < 2019-03-coins_thepool_life.sql +if [[ ("$wireguard" == "false") ]]; then + sudo sed -i '/max_connections/c\max_connections = 800' /etc/mysql/my.cnf sudo sed -i '/thread_cache_size/c\thread_cache_size = 512' /etc/mysql/my.cnf sudo sed -i '/tmp_table_size/c\tmp_table_size = 128M' /etc/mysql/my.cnf @@ -69,6 +105,17 @@ sudo sed -i '/max_heap_table_size/c\max_heap_table_size = 128M' /etc/mysql/m sudo sed -i '/wait_timeout/c\wait_timeout = 60' /etc/mysql/my.cnf sudo sed -i '/max_allowed_packet/c\max_allowed_packet = 64M' /etc/mysql/my.cnf + +else + sudo sed -i '/max_connections/c\max_connections = 800' /etc/mysql/my.cnf + sudo sed -i '/thread_cache_size/c\thread_cache_size = 512' /etc/mysql/my.cnf + sudo sed -i '/tmp_table_size/c\tmp_table_size = 128M' /etc/mysql/my.cnf + sudo sed -i '/max_heap_table_size/c\max_heap_table_size = 128M' /etc/mysql/my.cnf + sudo sed -i '/wait_timeout/c\wait_timeout = 60' /etc/mysql/my.cnf + sudo sed -i '/max_allowed_packet/c\max_allowed_packet = 64M' /etc/mysql/my.cnf + sudo sed -i 's/#bind-address=0.0.0.0/bind-address='${DBInternalIP}'/g' /etc/mysql/my.cnf +fi + restart_service mysql echo Database build complete... cd $HOME/multipool/yiimp_single diff --git a/menu.sh b/menu.sh index 8a8865b..86862f2 100644 --- a/menu.sh +++ b/menu.sh @@ -5,12 +5,10 @@ source /etc/functions.sh -RESULT=$(dialog --stdout --title "Ultimate Crypto-Server Setup Installer v1.26" --menu "Choose one" -1 60 5 \ +RESULT=$(dialog --stdout --title "Ultimate Crypto-Server Setup Installer v1.26" --menu "Choose one" -1 60 3 \ 1 "YiiMP - Single Server" \ 2 "YiiMP - Single Server with WireGuard" \ -3 "YiiMP - Add Stratum Server" \ -4 "YiiMP - Add Daemon Server" \ -5 Exit) +3 Exit) if [ $RESULT = ] then exit ; @@ -22,7 +20,7 @@ then clear; echo ' wireguard=false -' | sudo -E tee $HOME/multipool/daemon_builder/.wireguard.install.cnf >/dev/null 2>&1; +' | sudo -E tee $HOME/multipool/yiimp_single/.wireguard.install.cnf >/dev/null 2>&1; fi if [ $RESULT = 2 ] @@ -30,13 +28,13 @@ then clear; echo ' wireguard=true -' | sudo -E tee $HOME/multipool/daemon_builder/.wireguard.install.cnf >/dev/null 2>&1; +' | sudo -E tee $HOME/multipool/yiimp_single/.wireguard.install.cnf >/dev/null 2>&1; echo 'server_type='db' DBInternalIP='10.0.0.2' ' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; fi -if [ $RESULT = 5 ] +if [ $RESULT = 3 ] then clear; exit; diff --git a/questions.sh b/questions.sh index e465967..fbfa7c9 100644 --- a/questions.sh +++ b/questions.sh @@ -5,7 +5,7 @@ source /etc/functions.sh source /etc/multipool.conf -source $HOME/multipool/daemon_builder/.wireguard.install.cnf +source $HOME/multipool/yiimp_single/.wireguard.install.cnf message_box "Ultimate Crypto-Server Setup Installer v1.02" \ "You have choosen to install YiiMP Single Server! diff --git a/start.sh b/start.sh index a372dc7..c8db518 100644 --- a/start.sh +++ b/start.sh @@ -42,7 +42,7 @@ fi # Start the installation. source menu.sh -source $HOME/multipool/daemon_builder/.wireguard.install.cnf +source $HOME/multipool/yiimp_single/.wireguard.install.cnf if [[ ("$wireguard" == "true") ]]; then source wireguard.sh fi diff --git a/stratum.sh b/stratum.sh index 59aeb91..00beed9 100644 --- a/stratum.sh +++ b/stratum.sh @@ -4,7 +4,7 @@ source /etc/functions.sh source $STORAGE_ROOT/yiimp/.yiimp.conf - +source $HOME/multipool/yiimp_single/.wireguard.install.cnf echo Building blocknotify and stratum... cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/blocknotify diff --git a/system.sh b/system.sh index b0cf539..5cbdd36 100644 --- a/system.sh +++ b/system.sh @@ -6,7 +6,7 @@ clear source /etc/functions.sh source $STORAGE_ROOT/yiimp/.yiimp.conf -source $HOME/multipool/daemon_builder/.wireguard.install.cnf +source $HOME/multipool/yiimp_single/.wireguard.install.cnf # Set timezone echo Setting TimeZone to UTC... diff --git a/web.sh b/web.sh index cc47418..e4880b1 100644 --- a/web.sh +++ b/web.sh @@ -1,8 +1,14 @@ +#!/usr/bin/env bash + ##################################################### -# Created by cryptopool.builders for crypto use... +# 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 +source $STORAGE_ROOT/yiimp/.wireguard.conf source $STORAGE_ROOT/yiimp/.yiimp.conf echo Building web file structure and copying files... @@ -27,7 +33,7 @@ echo 'map $http_user_agent $blockedagent { } ' | sudo -E tee /etc/nginx/blockuseragents.rules >/dev/null 2>&1 -if [[ ("$UsingSubDomain" == "yes") ]]; then +if [[ ("$UsingSubDomain" == "y" || "$UsingSubDomain" == "Y" || "$UsingSubDomain" == "yes" || "$UsingSubDomain" == "Yes" || "$UsingSubDomain" == "YES") ]]; then echo 'include /etc/nginx/blockuseragents.rules; # NGINX Simple DDoS Defense @@ -144,7 +150,7 @@ sudo ln -s $STORAGE_ROOT/yiimp/site/web /var/www/${DomainName}/html restart_service nginx restart_service php7.2-fpm -if [[ ($InstallSSL" == "yes") ]]; then +if [[ ("$InstallSSL" == "y" || "$InstallSSL" == "Y" || "$InstallSSL" == "yes" || "$InstallSSL" == "Yes" || "$InstallSSL" == "YES") ]]; then echo Installing LetsEncrypt and setting up SSL... apt_install letsencrypt hide_output sudo letsencrypt certonly -a webroot --webroot-path=${STORAGE_ROOT}/yiimp/site/web --email "${SupportEmail}" --agree-tos -d "${DomainName}" @@ -582,6 +588,8 @@ define('"'"'EXCH_STOCKSEXCHANGE_SECRET'"'"', '"'"''"'"'); define('"'"'EXCH_YOBIT_SECRET'"'"', '"'"''"'"'); ' | sudo -E tee /etc/yiimp/keys.php >/dev/null 2>&1 +if [[ ("$wireguard" == "false") ]]; then + echo ' 5.0, );' | sudo -E tee $STORAGE_ROOT/yiimp/site/configuration/serverconfig.php >/dev/null 2>&1 +else + + echo ' + 0.3 + define('"'"'EXCH_AUTO_WITHDRAW'"'"', 0.3); + // nicehash keys deposit account & amount to deposit at a time + define('"'"'NICEHASH_API_KEY'"'"','"'"'521c254d-8cc7-4319-83d2-ac6c604b5b49'"'"'); + define('"'"'NICEHASH_API_ID'"'"','"'"'9205'"'"'); + define('"'"'NICEHASH_DEPOSIT'"'"','"'"'3J9tapPoFCtouAZH7Th8HAPsD8aoykEHzk'"'"'); + define('"'"'NICEHASH_DEPOSIT_AMOUNT'"'"','"'"'0.01'"'"'); + $cold_wallet_table = array( + '"'"'12Pt3vQhQpXvyzBd5qcoL17ouhNFyihyz5'"'"' => 0.10, + ); + // Sample fixed pool fees + $configFixedPoolFees = array( + '"'"'zr5'"'"' => 2.0, + '"'"'scrypt'"'"' => 20.0, + '"'"'sha256'"'"' => 5.0, + ); + // Sample custom stratum ports + $configCustomPorts = array( + // '"'"'x11'"'"' => 7000, + ); + // mBTC Coefs per algo (default is 1.0) + $configAlgoNormCoef = array( + // '"'"'x11'"'"' => 5.0, + );' | sudo -E tee $STORAGE_ROOT/yiimp/site/configuration/serverconfig.php >/dev/null 2>&1 +fi + echo Setting correct folder permissions... whoami=`whoami` sudo usermod -aG www-data $whoami diff --git a/wireguard.sh b/wireguard.sh index 4886e52..26224d8 100644 --- a/wireguard.sh +++ b/wireguard.sh @@ -2,6 +2,7 @@ # Created by cryptopool.builders for crypto use... ##################################################### +source $HOME/multipool/yiimp_single/.wireguard.install.cnf source $STORAGE_ROOT/yiimp/.wireguard.conf source /etc/multipool.conf diff --git a/wireguard_menu.sh b/wireguard_menu.sh deleted file mode 100644 index 5a0ca19..0000000 --- a/wireguard_menu.sh +++ /dev/null @@ -1,144 +0,0 @@ -##################################################### -# Source code https://github.com/end222/pacmenu -# Updated by cryptopool.builders for crypto use... -##################################################### - -source /etc/functions.sh -cd $HOME/multipool/yiimp_multi - -RESULT=$(dialog --stdout --title "Ultimate Crypto-Server Setup Installer" --menu "Choose one" -1 60 6 \ -1 "Install Wireguard on DB Server or DB-Stratum Server" \ -2 "Install Wireguard on Web Server" \ -3 "Install Wireguard on First Stratum Server Only" \ -4 "Install Wireguard on Daemon Server" \ -5 "Install Wireguard on Additional Server(s)" \ -6 Exit) -if [ $RESULT = ] -then -exit ; -fi - -if [ $RESULT = 1 ] -then -clear; -echo 'server_type='db' -DBInternalIP='10.0.0.2' -' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; -cd $HOME/multipool/yiimp_multi -source wireguard.sh; -exit ; -fi - -if [ $RESULT = 2 ] -then -clear; -read -e -p "Please enter the DB servers PUBLIC IP : " DBServerIP; -read -e -p "Please enter the DB public key that was displayed : " DBPublicKey; -echo 'server_type='web' -WebInternalIP='10.0.0.3' -DBInternalIP='10.0.0.2' -DBServerIP='"${DBServerIP}"' -DBPublicKey='"${DBPublicKey}"' -' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; -cd $HOME/multipool/yiimp_multi -source wireguard.sh; -exit ; -fi - -if [ $RESULT = 3 ] -then -clear; -read -e -p "Please enter the DB servers PUBLIC IP : " DBServerIP; -read -e -p "Please enter the DB public key that was displayed : " DBPublicKey; -echo 'server_type='stratum' -StratumInternalIP='10.0.0.4' -DBInternalIP='10.0.0.2' -DBServerIP='"${DBServerIP}"' -DBPublicKey='"${DBPublicKey}"' -' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; -cd $HOME/multipool/yiimp_multi -source wireguard.sh; -exit ; -fi - -if [ $RESULT = 4 ] -then -clear; -read -e -p "Please enter the DB servers PUBLIC IP : " DBServerIP; -read -e -p "Please enter the DB public key that was displayed : " DBPublicKey; -echo 'server_type='daemon' -DaemonInternalIP='10.0.0.5' -DBInternalIP='10.0.0.2' -DBServerIP='"${DBServerIP}"' -DBPublicKey='"${DBPublicKey}"' -' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; -cd $HOME/multipool/yiimp_multi -source wireguard.sh; -exit ; -fi - -if [ $RESULT = 5 ] -then -clear; -source wire_warning.sh - -if [ -z "$AdditionalInternalIP" ]; then -DEFAULT_AdditionalInternalIP='10.0.0.x' -input_box "Additional Server Private IP" \ -"Enter the new Private IP of this server. -\n\nMake sure not to reuse an IP already in use! -\n\nPrivate IP address:" \ -$DEFAULT_AdditionalInternalIP \ -AdditionalInternalIP - -if [ -z "$AdditionalInternalIP" ]; then -user hit ESC/cancel -exit -fi -fi - -if [ -z "$DBServerIP" ]; then -DEFAULT_DBServerIP='x.x.x.x' -input_box "DB Server Public IP" \ -"Enter the Public IP of your DB Server. -\n\nDB Public IP address:" \ -$DEFAULT_DBServerIP \ -DBServerIP - -if [ -z "$DBServerIP" ]; then -user hit ESC/cancel -exit -fi -fi - -if [ -z "$DBPublicKey" ]; then -DEFAULT_DBPublicKey='PublicKey' -input_box "DB Server Public Key" \ -"Enter the Public Key of your DB Server. -\n\nDB Public Key:" \ -$DEFAULT_DBPublicKey \ -DBPublicKey - -if [ -z "$DBPublicKey" ]; then -user hit ESC/cancel -exit -fi -fi - -echo 'server_type='additional' -AdditionalInternalIP='"${AdditionalInternalIP}"' -DBInternalIP='10.0.0.2' -DBServerIP='"${DBServerIP}"' -DBPublicKey='"${DBPublicKey}"' -' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard.conf >/dev/null 2>&1; -cd $HOME/multipool/yiimp_multi -source wireguard.sh; -exit ; -fi - -if [ $RESULT = 6 ] -then -clear; -exit; -fi -cd $HOME/multipool/yiimp_multi