From 4b259889575e293aa8326e56c63920333caaa664 Mon Sep 17 00:00:00 2001 From: jzgdev Date: Sat, 2 Jun 2018 05:55:25 -0700 Subject: [PATCH] add Docker deployment and FreeBSD/macOS support in install.sh --- Dockerfile | 46 +++++++++++++++++ README.md | 16 ++++-- install.sh | 142 +++++++++++++++++++++++++++++++++++++++++---------- package.json | 6 +-- 4 files changed, 177 insertions(+), 33 deletions(-) create mode 100644 Dockerfile mode change 100644 => 100755 install.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..22b2c38 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:16.04 +LABEL maintainer="JZG Dev" +LABEL Name="Dockerized xmr-node-proxy" +LABEL Version="1.4" +RUN export BUILD_DEPS="cmake \ + pkg-config \ + git \ + build-essential \ + curl \ + sudo"\ + && apt-get update && apt-get upgrade -qqy \ + && apt-get install ${BUILD_DEPS} -qqy \ + && curl -o- https://deb.nodesource.com/setup_6.x| bash \ + && apt-get install --no-install-recommends -qqy \ + python-virtualenv \ + python3-virtualenv ntp screen \ + libboost-all-dev libevent-dev nodejs \ + libunbound-dev libminiupnpc-dev \ + libunwind8-dev liblzma-dev libldns-dev \ + libexpat1-dev libgtest-dev libzmq3-dev \ + && echo "proxy ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +RUN mkdir /app \ + && mkdir -p /home/proxy \ + && chown -R proxy:proxy /home/proxy \ + && chown -R proxy:proxy /app +USER proxy +ENV HOME=/home/proxy/ +WORKDIR $HOME +RUN sudo chown -R proxy.proxy $(npm config get prefix)/lib/node_modules \ + && sudo npm config set prefix '/home/proxy/.npm-global' +ENV PATH=/home/proxy/.npm-global/bin:${PATH} +RUN git clone https://github.com/Snipa22/xmr-node-proxy /app \ + && npm install -g pm2 \ + && cd /app && npm install +CMD ["pm2-runtime", "status"] +RUN cd /app \ + && openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.proxy" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 +USER root +RUN apt-get --auto-remove purge -qqy ${BUILD_DEPS} \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir /app/logs +USER proxy +WORKDIR /app +CMD ["pm2-runtime", "install", "pm2-logrotate"] +CMD ["pm2-runtime", "proxy.js"] \ No newline at end of file diff --git a/README.md b/README.md index a390fe1..46d968f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,21 @@ # xmr-node-proxy +## Deployment via Docker +- *note* xmr-node-proxy needs requires a properly configured `config.json`. + - `mv config.json.example config.json` and edit the newly created `config.json` + - `docker build -f ./Dockerfile .` + - `docker container run -v $(pwd)/config.json:/app/config.json -p 3333:3333 --name proxy -d jzgdev/xmr-node-proxy` -## Setup Instructions - -Based on a clean Ubuntu 16.04 LTS minimal install +- Monitor with `bash -c "clear && docker exec -it xmr sh" && pm2 monit` ## Deployment via Installer +Compatible with: + +- Ubuntu 14.04 +- FreeBSD 11.1 +- macOS High Sierra + 1. Create a user 'nodeproxy' and assign a password (or add an SSH key. If you prefer that, you should already know how to do it) ```bash @@ -79,6 +88,7 @@ The proxy is pre-configured for a 1% donation. This is easily toggled inside of * XMR - 44Ldv5GQQhP7K7t3ZBdZjkPA7Kg7dhHwk3ZM3RJqxxrecENSFx27Vq14NAMAd2HBvwEPUVVvydPRLcC69JCZDHLT2X5a4gr * BTC - 15fkPTtN8cRXD3moKWDoXjuiTaS9FgA3UE +* ETH - 0x490184777c1eeb306927ded6baa6edf46d08298c ## Installation/Configuration Assistance diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index f09f059..3bdd18e --- a/install.sh +++ b/install.sh @@ -1,29 +1,117 @@ #!/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 +platform='unknown'; unamestr=`uname`; +if [[ "$unamestr" == 'Linux' ]]; then + platform='linux' + echo "This assumes that you are doing a green-field install for $unamestr. If you're not, please exit in the next 5 seconds with '^C'." + sleep 5 + 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 + CURUSER=$(whoami) + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install 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 libgtest-dev libzmq3-dev + cd ~ + git clone https://github.com/Snipa22/xmr-node-proxy + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash + source ~/.nvm/nvm.sh + nvm install v6.9.2 + cd ~/xmr-node-proxy + npm install + npm install -g pm2 + cp config_example.json config.json + openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.proxy" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 + cd ~ + pm2 status + sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` + sudo chown -R $CURUSER. ~/.pm2 + echo "Installing pm2-logrotate in the background!" + pm2 install pm2-logrotate & + echo "You're setup with a shiny new proxy! Now, go configure it and have fun." + +elif [[ "$unamestr" == 'FreeBSD' ]]; then + + #!/usr/local/bin/bash + platform='freebsd' + echo "This assumes that you are doing a green-field install for $unamestr. If you're not, please exit in the next 5 seconds with '^C'." + sleep 5 + 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 + CURUSER=$(whoami) + sudo pkg update && pkg upgrade -y + sudo pkg install -y git \ + py27-virtualenv py36-virtualenv \ + curl ntp screen \ + cmake boost-libs libevent \ + unbound miniupnpc libunwind \ + lzmalib ldns-1.7.0_1 expat \ + googletest libzmq3 glib \ + gmake-4.2.1_2 clang35-3.5.2_4 \ + gcc node6-6.14.1_1 npm-node6-5.7.1 + cd ~ + git clone https://github.com/Snipa22/xmr-node-proxy + cd ~/xmr-node-proxy + echo 'export CC="gcc"' >> ~/.bashrc + echo 'export CXX="g++"' >> ~/.bashrc + echo 'export CXXFLAGS="-g"' >> ~/.bashrc + sudo chown -R $CURUSER /usr/local/lib/node_modules/ + sudo chown $CURUSER /usr/local/bin + sudo chown $CURUSER /usr/local/share + /usr/local/bin/npm install + /usr/local/bin/npm install -g pm2 + cp config_example.json config.json; + sudo openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.proxy" -days 36500 -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem; + cd ~ + /usr/local/bin/pm2 status + sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup rcd -u nodeproxy --hp /home/nodeproxy + sudo chown -R $CURUSER ~/.pm2 + echo "Installing pm2-logrotate in the background!" + /usr/local/bin/pm2 install pm2-logrotate & + echo "You're setup with a shiny new proxy! Now, go configure it and have fun." +elif [[ "$unamestr" == 'Darwin' ]]; then + platform='darwin' + echo "This assumes that you are doing a green-field install for $unamestr. If you're not, please exit in the next 5 seconds with '^C'." + sleep 5 + 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 + CURUSER=$(whoami) + if [ ! -d "/Users/${CURUSER}/Library/Caches/Homebrew" ]; + then /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ; + else + BREW=$(brew update) + if [ "$BREW" != "Already up-to-date." ] + then /usr/local/bin/brew upgrade + echo "brew has succesfully updated and upgraded remote homebrew packages." + else echo "$BREW" + fi + fi + brew install git pyenv curl ntp gcc cmake screen cmake pkg-config boost boost-python boost-python3 libevent unbound miniupnpc libunwind-headers xz ldns expat zmq + cd ~/Desktop + git clone https://github.com/Snipa22/xmr-node-proxy + cd ~/Desktop/xmr-node-proxy + if [ -d "/Users/${CURUSER}/n/" ]; then n 6.9.2 ; + elif [ -d "/Users/${CURUSER}/n/" ]; then nvm install v6.9.2; + else curl -L https://git.io/n-install | bash && n 6.9.2; + fi + npm install -g Unitech/pm2#development && pm2 update + npm install + cp config_example.json config.json + openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.proxy" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 + cd ~ + PM2_VARS=$(pm2 startup) + START_PM2=$(echo "$PM2_VARS" | sed -n -e '/env/,$p') + sudo chown -R $CURUSER ~/.pm2 + sudo $START_PM2 + echo "Installing pm2-logrotate in the background!" + pm2 install pm2-logrotate + echo "You're setup with a shiny new proxy! Now, go configure it and have fun." fi -CURUSER=$(whoami) -sudo apt-get update -sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install 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 libgtest-dev libzmq3-dev -cd ~ -git clone https://github.com/Snipa22/xmr-node-proxy -curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash -source ~/.nvm/nvm.sh -nvm install v6.9.2 -cd ~/xmr-node-proxy -npm install -npm install -g pm2 -cp config_example.json config.json -openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.proxy" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 -cd ~ -pm2 status -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` -sudo chown -R $CURUSER. ~/.pm2 -echo "Installing pm2-logrotate in the background!" -pm2 install pm2-logrotate & -echo "You're setup with a shiny new proxy! Now, go configure it and have fun." + diff --git a/package.json b/package.json index d674457..286030a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "optionalDependencies": { "cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0", - "multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git#v0.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git" + "multi-hashing": "git://github.com/clintar/node-multi-hashing.git#Nan-2.0", + "cryptonight-hashing": "*" } -} +} \ No newline at end of file