Skip to content

Commit

Permalink
wireguard update
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptopool-builders committed Mar 13, 2019
1 parent d29b4fc commit f87f22b
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 160 deletions.
51 changes: 49 additions & 2 deletions db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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}"'
Expand All @@ -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

Expand Down Expand Up @@ -62,13 +96,26 @@ 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
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


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
12 changes: 5 additions & 7 deletions menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand All @@ -22,21 +20,21 @@ 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 ]
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;
Expand Down
2 changes: 1 addition & 1 deletion questions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stratum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
99 changes: 96 additions & 3 deletions web.sh
Original file line number Diff line number Diff line change
@@ -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...
Expand All @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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 '
<?php
ini_set('"'"'date.timezone'"'"', '"'"'UTC'"'"');
Expand Down Expand Up @@ -664,6 +672,91 @@ $configAlgoNormCoef = array(
// '"'"'x11'"'"' => 5.0,
);' | sudo -E tee $STORAGE_ROOT/yiimp/site/configuration/serverconfig.php >/dev/null 2>&1

else

echo '
<?php
ini_set('"'"'date.timezone'"'"', '"'"'UTC'"'"');
define('"'"'YAAMP_LOGS'"'"', '"'"''"${STORAGE_ROOT}/yiimp/site/log"''"'"');
define('"'"'YAAMP_HTDOCS'"'"', '"'"''"${STORAGE_ROOT}/yiimp/site/web"''"'"');
define('"'"'YAAMP_BIN'"'"', '"'"'/bin'"'"');
define('"'"'YAAMP_DBHOST'"'"', '"'"''"${DBInternalIP}"''"'"');
define('"'"'YAAMP_DBNAME'"'"', '"'"'yiimpfrontend'"'"');
define('"'"'YAAMP_DBUSER'"'"', '"'"'panel'"'"');
define('"'"'YAAMP_DBPASSWORD'"'"', '"'"''"${PanelUserDBPassword}"''"'"');
define('"'"'YAAMP_PRODUCTION'"'"', true);
define('"'"'YAAMP_RENTAL'"'"', false);
define('"'"'YAAMP_LIMIT_ESTIMATE'"'"', false);
define('"'"'YAAMP_FEES_MINING'"'"', 0.5);
define('"'"'YAAMP_FEES_EXCHANGE'"'"', 2);
define('"'"'YAAMP_FEES_RENTING'"'"', 2);
define('"'"'YAAMP_TXFEE_RENTING_WD'"'"', 0.002);
define('"'"'YAAMP_PAYMENTS_FREQ'"'"', 3*60*60);
define('"'"'YAAMP_PAYMENTS_MINI'"'"', 0.001);
define('"'"'YAAMP_ALLOW_EXCHANGE'"'"', false);
define('"'"'YIIMP_PUBLIC_EXPLORER'"'"', false);
define('"'"'YIIMP_PUBLIC_BENCHMARK'"'"', false);
define('"'"'YIIMP_FIAT_ALTERNATIVE'"'"', '"'"'USD'"'"'); // USD is main
define('"'"'YAAMP_USE_NICEHASH_API'"'"', false);
define('"'"'YAAMP_BTCADDRESS'"'"', '"'"'12Pt3vQhQpXvyzBd5qcoL17ouhNFyihyz5'"'"');
define('"'"'YAAMP_SITE_URL'"'"', '"'"''"${DomainName}"''"'"');
define('"'"'YAAMP_STRATUM_URL'"'"', '"'"''"${StratumURL}"''"'"'); // change if your stratum server is on a different host
define('"'"'YAAMP_SITE_NAME'"'"', '"'"'CryptoPool.Builders'"'"');
define('"'"'YAAMP_ADMIN_EMAIL'"'"', '"'"''"${SupportEmail}"''"'"');
define('"'"'YAAMP_ADMIN_IP'"'"', '"'"''"${PublicIP}"''"'"'); // samples: "80.236.118.26,90.234.221.11" or "10.0.0.1/8"
define('"'"'YAAMP_ADMIN_WEBCONSOLE'"'"', true);
define('"'"'YAAMP_CREATE_NEW_COINS'"'"', false);
define('"'"'YAAMP_NOTIFY_NEW_COINS'"'"', false);
define('"'"'YAAMP_DEFAULT_ALGO'"'"', '"'"'x11'"'"');
define('"'"'YAAMP_USE_NGINX'"'"', true);
// Exchange public keys (private keys are in a separate config file)
define('"'"'EXCH_CRYPTOPIA_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_POLONIEX_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_BITTREX_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_BLEUTRADE_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_BTER_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_YOBIT_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_CCEX_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_CEXIO_ID'"'"', '"'"''"'"');
define('"'"'EXCH_CEXIO_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_COINMARKETS_USER'"'"', '"'"''"'"');
define('"'"'EXCH_COINMARKETS_PIN'"'"', '"'"''"'"');
define('"'"'EXCH_CREX24_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_BINANCE_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_BITSTAMP_ID'"'"', '"'"''"'"');
define('"'"'EXCH_BITSTAMP_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_HITBTC_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_KRAKEN_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_KUCOIN_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_LIVECOIN_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_NOVA_KEY'"'"', '"'"''"'"');
define('"'"'EXCH_STOCKSEXCHANGE_KEY'"'"', '"'"''"'"');
// Automatic withdraw to Yaamp btc wallet if btc balance > 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
Expand Down
1 change: 1 addition & 0 deletions wireguard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit f87f22b

Please sign in to comment.