Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptopool-builders committed Nov 28, 2018
1 parent 8705ac0 commit d3402ef
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 92 deletions.
9 changes: 5 additions & 4 deletions db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ source $STORAGE_ROOT/yiimp/.yiimp.conf

echo Installing MariaDB...
MARIADB_VERSION='10.3'
sudo debconf-set-selections <<< "maria-db-$MARIADB_VERSION mysql-server/root_password password $DBRootPassword"
sudo debconf-set-selections <<< "maria-db-$MARIADB_VERSION mysql-server/root_password_again password $DBRootPassword"
sudo debconf-set-selections <<< "maria-db-$MARIADB_VERSION mysql-server/root_password password ${DBRootPassword}"
sudo debconf-set-selections <<< "maria-db-$MARIADB_VERSION mysql-server/root_password_again password ${DBRootPassword}"
apt_install mariadb-server mariadb-client

echo Creating DB users for YiiMP...
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 *.* TO 'panel'@'localhost' IDENTIFIED BY '${PanelUserDBPassword}';"
Q3="GRANT ALL ON *.* TO 'stratum'@'localhost' IDENTIFIED BY '${StratumUserDBPassword}';"
Q4="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}${Q4}"
sudo mysql -u root -p"${DBRootPassword}" -e "$SQL"
Expand Down Expand Up @@ -67,6 +67,7 @@ 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

restart_service mysql
echo Database build complete...
cd $HOME/multipool/yiimp_single
120 changes: 66 additions & 54 deletions questions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,149 +12,157 @@ message_box "Ultimate Crypto-Server Setup Installer v1.02" \
\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!"

if [ -z "$UsingSubDomain" ]; then
DEFAULT_UsingSubDomain=no
input_box "Using Sub-Domain" \
"Are you using a sub-domain for the main website domain? Example pool.example.com?
\n\nPlease answer (y)es or (n)o only:" \
$DEFAULT_UsingSubDomain \
UsingSubDomain

if [ -z "$UsingSubDomain" ]; then
# user hit ESC/cancel
exit
fi
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 "$InstallSSL" ]; then
DEFAULT_InstallSSL=yes
input_box "Install SSL" \
"Would you like the system to install SSL automatically?
\n\nPlease answer (y)es or (n)o only:" \
$DEFAULT_InstallSSL \
InstallSSL
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 "$InstallSSL" ]; 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 "$DomainName" ]; then
if [ -z "${DomainName}" ]; then
DEFAULT_DomainName=$(get_publicip_from_web_service 4 || get_default_privateip 4)
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 \
${DEFAULT_DomainName} \
DomainName

if [ -z "$DomainName" ]; then
if [ -z "${DomainName}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$StratumURL" ]; then
DEFAULT_StratumURL=stratum.$DomainName
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
"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 \
${DEFAULT_StratumURL} \
StratumURL

if [ -z "$StratumURL" ]; then
if [ -z "${StratumURL}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$SupportEmail" ]; then
DEFAULT_SupportEmail=support@$DomainName
if [ -z "${SupportEmail}" ]; then
DEFAULT_SupportEmail=support@${DomainName}
input_box "System Email" \
"Enter an email address for the system to send alerts and other important messages.
\n\nSystem Email:" \
$DEFAULT_SupportEmail \
${DEFAULT_SupportEmail} \
SupportEmail

if [ -z "$SupportEmail" ]; then
if [ -z "${SupportEmail}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$PublicIP" ]; then
if [ -z "${PublicIP}" ]; then
DEFAULT_PublicIP=$(echo $SSH_CLIENT | awk '{ print $1}')
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 \
${DEFAULT_PublicIP} \
PublicIP

if [ -z "$PublicIP" ]; then
if [ -z "${PublicIP}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$DBRootPassword" ]; then
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 \
${DEFAULT_DBRootPassword} \
DBRootPassword

if [ -z "$DBRootPassword" ]; then
if [ -z "${DBRootPassword}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$PanelUserDBPassword" ]; then
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 \
${DEFAULT_PanelUserDBPassword} \
PanelUserDBPassword

if [ -z "$PanelUserDBPassword" ]; then
if [ -z "${PanelUserDBPassword}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$StratumUserDBPassword" ]; then
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 \
${DEFAULT_StratumUserDBPassword} \
StratumUserDBPassword

if [ -z "$StratumUserDBPassword" ]; then
if [ -z "${StratumUserDBPassword}" ]; then
# user hit ESC/cancel
exit
fi
fi

if [ -z "$AdminPanel" ]; then
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\nOnce set you will access the YiiMP admin at ${DomainName}/site/AdminPortal
\n\nDesired Admin Panel Location:" \
$DEFAULT_AdminPanel \
${DEFAULT_AdminPanel} \
AdminPanel

if [ -z "$AdminPanel" ]; then
if [ -z "${AdminPanel}" ]; then
# user hit ESC/cancel
exit
fi
Expand All @@ -165,13 +173,15 @@ clear
dialog --title "Verify Your Responses" \
--yesno "Please verify your answers to continue setup:
Dedicated Coin Ports : ${CoinPort}
AutoExchange : ${AutoExchange}
Using Sub-Domain : ${UsingSubDomain}
Install SSL : ${InstallSSL}
Domain Name : ${DomainName}
Stratum URL : ${StratumURL}
System Email : ${SupportEmail}
Your Public IP : ${PublicIP}
Admin Location : ${AdminPanel}" 13 60
Admin Location : ${AdminPanel}" 20 60


# Get exit status
Expand All @@ -196,6 +206,8 @@ PanelUserDBPassword='"'"''"${PanelUserDBPassword}"''"'"'
StratumUserDBPassword='"'"''"${StratumUserDBPassword}"''"'"'
UsingSubDomain='"${UsingSubDomain}"'
InstallSSL='"${InstallSSL}"'
CoinPort='"${CoinPort}"'
AutoExchange='"${AutoExchange}"'
# 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 ;;
Expand Down
10 changes: 5 additions & 5 deletions send_mail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ source $STORAGE_ROOT/yiimp/.yiimp.conf

echo "Installing mail system"

echo $DomainName | hide_output sudo tee -a /etc/hostname
sudo hostname "$DomainName"
echo ${DomainName} | hide_output sudo tee -a /etc/hostname
sudo hostname "${DomainName}"

sudo debconf-set-selections <<< "postfix postfix/mailname string $host_name"
sudo debconf-set-selections <<< "postfix postfix/mailname string ${host_name}"
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
apt_install mailutils

Expand All @@ -22,8 +22,8 @@ sudo sed -i '/#mydestination/i mydestination = $myhostname, localhost.$mydomain,
sudo systemctl restart postfix
whoami=`whoami`

sudo sed -i '/postmaster: root/a root: '$SupportEmail'' /etc/aliases
sudo sed -i '/root:/a '$whoami': '$SupportEmail'' /etc/aliases
sudo sed -i '/postmaster: root/a root: '${SupportEmail}'' /etc/aliases
sudo sed -i '/root:/a '$whoami': '${SupportEmail}'' /etc/aliases
sudo newaliases

sudo adduser $whoami mail
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ echo You *MUST* reboot the machine to finalize the machine updates and folder pe
echo
echo "Important! After first reboot it may take up to 1 minute for the main|loop2|blocks|debug screens to start!"
echo "After 1 minute, type motd to refresh"
echo You can access your admin panel at, http://$DomainName/site/$AdminPanel
echo You can access your admin panel at, http://${DomainName}/site/${AdminPanel}
echo
echo By default all stratum ports are blocked by the firewall. To allow a port through, from the command prompt type sudo ufw allow port number.
echo Database user names and passwords can be found in $STORAGE_ROOT/yiimp_setup/.my.cnf
15 changes: 11 additions & 4 deletions stratum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ source /etc/functions.sh
source $STORAGE_ROOT/yiimp/.yiimp.conf

echo Building blocknotify and stratum...
cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
if [[ ("$CoinPort" == "y" || "$CoinPort" == "Y" || "$CoinPort" == "yes" || "$CoinPort" == "Yes" || "$CoinPort" == "YES") ]]; then
git fetch
git checkout multi-port
fi
cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/blocknotify
blckntifypass=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`
sudo sed -i 's/tu8tu5/'$blckntifypass'/' blocknotify.cpp
sudo sed -i 's/tu8tu5/'${blckntifypass}'/' blocknotify.cpp
hide_output sudo make
cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum/iniparser
hide_output sudo make
cd $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum
if [[ ("$AutoExchange" == "y" || "$AutoExchange" == "Y" || "$AutoExchange" == "yes" || "$AutoExchange" == "Yes" || "$AutoExchange" == "YES") ]]; then
sudo sed -i 's/CFLAGS += -DNO_EXCHANGE/#CFLAGS += -DNO_EXCHANGE/' $STORAGE_ROOT/yiimp/yiimp_setup/yiimp/stratum/Makefile
fi
hide_output sudo make

echo Building stratum folder structure and copying files...
Expand Down Expand Up @@ -52,12 +59,12 @@ sudo chmod +x $STORAGE_ROOT/yiimp/site/stratum/run.sh

echo Updating stratum config files with database connection info...
cd $STORAGE_ROOT/yiimp/site/stratum/config
sudo sed -i 's/password = tu8tu5/password = '$blckntifypass'/g' *.conf
sudo sed -i 's/server = yaamp.com/server = '$StratumURL'/g' *.conf
sudo sed -i 's/password = tu8tu5/password = '${blckntifypass}'/g' *.conf
sudo sed -i 's/server = yaamp.com/server = '${StratumURL}'/g' *.conf
sudo sed -i 's/host = yaampdb/host = localhost/g' *.conf
sudo sed -i 's/database = yaamp/database = yiimpfrontend/g' *.conf
sudo sed -i 's/username = root/username = stratum/g' *.conf
sudo sed -i 's/password = patofpaq/password = '$StratumUserDBPassword'/g' *.conf
sudo sed -i 's/password = patofpaq/password = '${StratumUserDBPassword}'/g' *.conf

echo Stratum build complete...
cd $HOME/multipool/yiimp_single
2 changes: 1 addition & 1 deletion system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ build-essential libtool autotools-dev automake pkg-config openssl=1.0.2g-1ubuntu


echo Downloading selected YiiMP Repo...
hide_output sudo git clone $YiiMPRepo $STORAGE_ROOT/yiimp/yiimp_setup/yiimp
hide_output sudo git clone ${YiiMPRepo} $STORAGE_ROOT/yiimp/yiimp_setup/yiimp

cd $HOME/multipool/yiimp_single
Loading

0 comments on commit d3402ef

Please sign in to comment.