#!/bin/bash echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." sleep 15 echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" if [[ `whoami` == "root" ]]; then echo "You ran me as root! Do not run me as root!" exit 1 fi ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) CURUSER=$(whoami) sudo timedatectl set-timezone Etc/UTC sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev nginx mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/xmrfast/nodejs-pool.git # Change this depending on how the deployment goes. cd ~ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.1.9 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload sudo systemctl enable monero sudo systemctl start monero cd ~ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash source ~/.nvm/nvm.sh nvm install v8.11.3 nvm alias default v8.11.3 cd ~/nodejs-pool npm install npm install -g pm2 openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.pool" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 mkdir ~/pool_db/ sed -r "s/(\"db_storage_path\": ).*/\1\"\/home\/$CURUSER\/pool_db\/\",/" config_example.json > config.json cd ~ git clone https://github.com/mesh0000/poolui.git cd poolui npm install ./node_modules/bower/bin/bower update ./node_modules/gulp/bin/gulp.js build cd build sudo ln -s `pwd` /var/www cd ~ sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin `pwd`/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool sudo chown -R $CURUSER. ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate & mysql -u root --password=$ROOT_SQL_PASS < deployment/base.sql mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api bash ~/nodejs-pool/deployment/install_lmdb_tools.sh cd ~/nodejs-pool/sql_sync/ env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin node sql_sync.js echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!"