2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2019-07-28 23:34:08 +00:00
|
|
|
set -x
|
2019-11-16 05:09:15 +00:00
|
|
|
set -e
|
2019-07-28 23:34:08 +00:00
|
|
|
|
2019-11-22 02:41:05 +00:00
|
|
|
# Make sure time is in the log
|
|
|
|
date
|
|
|
|
|
2019-07-28 23:34:08 +00:00
|
|
|
# Shut down main services to save memory and CPU
|
|
|
|
systemctl stop electrs
|
2019-08-10 01:07:46 +00:00
|
|
|
systemctl stop lnd
|
2019-07-28 23:34:08 +00:00
|
|
|
systemctl stop quicksync
|
2019-08-10 01:07:46 +00:00
|
|
|
systemctl stop bitcoind
|
2019-07-28 23:34:08 +00:00
|
|
|
|
2019-11-25 03:45:24 +00:00
|
|
|
# Check for updates (might auto-install all updates later)
|
|
|
|
apt-get update
|
|
|
|
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Install any new software
|
2019-11-25 03:45:24 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
apt-get -y install fonts-dejavu
|
|
|
|
apt-get -y install pv sysstat network-manager unzip pkg-config libfreetype6-dev libpng-dev
|
|
|
|
apt-get -y install libatlas-base-dev libffi-dev libssl-dev glances python3-bottle
|
|
|
|
apt-get -y -qq install apt-transport-https ca-certificates
|
|
|
|
apt-get -y install libgmp-dev automake libtool libltdl-dev libltdl7
|
|
|
|
apt-get -y install xorg chromium openbox lightdm
|
|
|
|
|
2019-11-26 13:49:24 +00:00
|
|
|
# Make sure some software is removed
|
|
|
|
apt-get -y purge ntp # (conflicts with systemd-timedatectl)
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
# Install any pip software
|
2019-11-25 03:45:24 +00:00
|
|
|
pip install tzupdate virtualenv --no-cache-dir
|
2019-08-08 01:46:58 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-08-18 03:30:21 +00:00
|
|
|
# Install any pip3 software
|
2019-11-25 03:45:24 +00:00
|
|
|
pip3 install python-bitcointx --no-cache-dir
|
2019-11-27 00:19:33 +00:00
|
|
|
pip3 install lndmanage==0.8.0.1 --no-cache-dir # Install LND Manage (keep up to date with LND)
|
2019-11-25 03:45:24 +00:00
|
|
|
pip3 install docker-compose --no-cache-dir
|
2019-08-18 03:30:21 +00:00
|
|
|
|
2019-10-16 02:10:40 +00:00
|
|
|
|
|
|
|
# Import Keys
|
|
|
|
curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import
|
2019-11-21 02:02:33 +00:00
|
|
|
curl https://raw.githubusercontent.com/JoinMarket-Org/joinmarket-clientserver/master/pubkeys/AdamGibson.asc | gpg --import
|
2019-10-16 02:10:40 +00:00
|
|
|
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964
|
|
|
|
|
|
|
|
|
2019-11-11 03:22:39 +00:00
|
|
|
# Install docker
|
2019-11-25 03:45:24 +00:00
|
|
|
if [ ! -f /usr/bin/docker ]; then
|
|
|
|
rm -f /tmp/docker_install.sh
|
|
|
|
wget https://get.docker.com -O /tmp/docker_install.sh
|
|
|
|
sed -i 's/sleep 20/sleep 1/' /tmp/docker_install.sh
|
|
|
|
/bin/bash /tmp/docker_install.sh
|
|
|
|
fi
|
|
|
|
|
2019-11-26 00:13:33 +00:00
|
|
|
# Use systemd for managing docker
|
|
|
|
rm -f /etc/init.d/docker
|
|
|
|
rm -f /etc/systemd/system/multi-user.target.wants/docker.service
|
|
|
|
systemctl -f enable docker.service
|
|
|
|
|
2019-11-11 03:22:39 +00:00
|
|
|
groupadd docker || true
|
|
|
|
usermod -aG docker admin
|
|
|
|
usermod -aG docker bitcoin
|
|
|
|
usermod -aG docker root
|
|
|
|
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Upgrade BTC
|
2019-11-21 02:02:33 +00:00
|
|
|
echo "Upgrading BTC..."
|
2019-11-16 05:09:15 +00:00
|
|
|
set +e
|
2019-10-16 02:57:46 +00:00
|
|
|
BTC_VERSION="0.18.1"
|
2019-06-15 23:02:44 +00:00
|
|
|
ARCH="arm-linux-gnueabihf"
|
|
|
|
uname -a | grep aarch64
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
ARCH="aarch64-linux-gnu"
|
|
|
|
fi
|
2019-10-03 03:10:20 +00:00
|
|
|
if [ $IS_X86 = 1 ]; then
|
|
|
|
ARCH="x86_64-linux-gnu"
|
|
|
|
fi
|
2019-11-16 05:09:15 +00:00
|
|
|
set -e
|
2019-10-16 02:57:46 +00:00
|
|
|
BTC_UPGRADE_URL=https://bitcoincore.org/bin/bitcoin-core-$BTC_VERSION/bitcoin-$BTC_VERSION-$ARCH.tar.gz
|
2019-06-15 23:02:44 +00:00
|
|
|
BTC_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.btc_url
|
2019-10-16 02:57:46 +00:00
|
|
|
BTC_UPGRADE_SHA256SUM_URL=https://bitcoincore.org/bin/bitcoin-core-$BTC_VERSION/SHA256SUMS.asc
|
2019-06-15 23:02:44 +00:00
|
|
|
CURRENT=""
|
|
|
|
if [ -f $BTC_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $BTC_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$BTC_UPGRADE_URL" ]; then
|
|
|
|
# Download and install Bitcoin
|
2019-10-16 02:57:46 +00:00
|
|
|
rm -rf /tmp/download
|
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
|
|
|
|
|
|
|
wget $BTC_UPGRADE_URL
|
|
|
|
wget $BTC_UPGRADE_SHA256SUM_URL -O SHA256SUMS.asc
|
|
|
|
|
|
|
|
sha256sum --ignore-missing --check SHA256SUMS.asc
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
gpg --verify SHA256SUMS.asc
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
# Install Bitcoin
|
2019-10-16 03:19:02 +00:00
|
|
|
tar -xvf bitcoin-$BTC_VERSION-$ARCH.tar.gz
|
|
|
|
mv bitcoin-$BTC_VERSION bitcoin
|
2019-10-16 02:57:46 +00:00
|
|
|
install -m 0755 -o root -g root -t /usr/local/bin bitcoin/bin/*
|
|
|
|
|
|
|
|
# Mark current version
|
|
|
|
echo $BTC_UPGRADE_URL > $BTC_UPGRADE_URL_FILE
|
|
|
|
else
|
|
|
|
echo "ERROR UPGRADING BITCOIN - GPG FAILED"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ERROR UPGRADING BITCOIN - SHASUM FAILED"
|
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Upgrade LND
|
2019-11-21 02:02:33 +00:00
|
|
|
echo "Upgrading LND..."
|
2019-10-16 02:10:40 +00:00
|
|
|
LND_VERSION="v0.8.0-beta"
|
|
|
|
LND_ARCH="lnd-linux-armv7"
|
2019-10-03 03:10:20 +00:00
|
|
|
if [ $IS_X86 = 1 ]; then
|
2019-10-16 02:10:40 +00:00
|
|
|
LND_ARCH="lnd-linux-amd64"
|
2019-10-03 03:10:20 +00:00
|
|
|
fi
|
2019-10-16 02:10:40 +00:00
|
|
|
LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/$LND_VERSION/$LND_ARCH-$LND_VERSION.tar.gz
|
2019-06-15 23:02:44 +00:00
|
|
|
LND_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnd_url
|
2019-10-16 02:10:40 +00:00
|
|
|
LND_UPGRADE_MANIFEST_URL=https://github.com/lightningnetwork/lnd/releases/download/$LND_VERSION/manifest-$LND_VERSION.txt
|
|
|
|
LND_UPGRADE_MANIFEST_SIG_URL=https://github.com/lightningnetwork/lnd/releases/download/$LND_VERSION/manifest-$LND_VERSION.txt.sig
|
2019-06-15 23:02:44 +00:00
|
|
|
CURRENT=""
|
|
|
|
if [ -f $LND_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $LND_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$LND_UPGRADE_URL" ]; then
|
|
|
|
# Download and install LND
|
2019-10-16 02:10:40 +00:00
|
|
|
rm -rf /tmp/download
|
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
|
|
|
|
2019-10-16 02:57:46 +00:00
|
|
|
wget $LND_UPGRADE_URL
|
|
|
|
wget $LND_UPGRADE_MANIFEST_URL
|
|
|
|
wget $LND_UPGRADE_MANIFEST_SIG_URL
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-10-16 02:57:46 +00:00
|
|
|
gpg --verify manifest-*.txt.sig
|
2019-10-16 02:10:40 +00:00
|
|
|
if [ $? == 0 ]; then
|
|
|
|
# Install LND
|
2019-10-16 02:57:46 +00:00
|
|
|
tar -xzf lnd-*.tar.gz
|
|
|
|
mv $LND_ARCH-$LND_VERSION lnd
|
2019-10-16 02:10:40 +00:00
|
|
|
install -m 0755 -o root -g root -t /usr/local/bin lnd/*
|
|
|
|
|
|
|
|
# Mark current version
|
|
|
|
echo $LND_UPGRADE_URL > $LND_UPGRADE_URL_FILE
|
|
|
|
else
|
|
|
|
echo "ERROR UPGRADING LND - GPG FAILED"
|
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-21 02:02:33 +00:00
|
|
|
# Install recent version of secp256k1
|
|
|
|
echo "Installing secp256k1..."
|
|
|
|
if [ ! -f /usr/include/secp256k1_ecdh.h ]; then
|
|
|
|
rm -rf /tmp/secp256k1
|
|
|
|
cd /tmp/
|
|
|
|
git clone https://github.com/bitcoin-core/secp256k1.git
|
|
|
|
cd secp256k1
|
|
|
|
|
|
|
|
./autogen.sh
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cp -f include/* /usr/include/
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Upgrade Joinmarket
|
|
|
|
echo "Upgrading JoinMarket..."
|
|
|
|
if [ $IS_PREMIUM -eq 1 ]; then
|
|
|
|
JOINMARKET_VERSION=0.5.5
|
|
|
|
JOINMARKET_GITHUB_URL=https://github.com/JoinMarket-Org/joinmarket-clientserver.git
|
|
|
|
JOINMARKET_VERSION_FILE=/home/bitcoin/.mynode/.joinmarket_version
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $JOINMARKET_VERSION_FILE ]; then
|
|
|
|
CURRENT=$(cat $JOINMARKET_VERSION_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$JOINMARKET_VERSION" ]; then
|
|
|
|
# Download and build JoinMarket
|
|
|
|
cd /opt/mynode
|
|
|
|
|
|
|
|
if [ ! -d /opt/mynode/joinmarket-clientserver ]; then
|
|
|
|
git clone $JOINMARKET_GITHUB_URL
|
|
|
|
cd joinmarket-clientserver
|
|
|
|
else
|
|
|
|
cd joinmarket-clientserver
|
|
|
|
git pull origin master
|
|
|
|
fi
|
|
|
|
git reset --hard v$JOINMARKET_VERSION
|
|
|
|
|
|
|
|
# Create virtualenv and setup joinmarket
|
|
|
|
virtualenv -p python3 jmvenv
|
|
|
|
source jmvenv/bin/activate
|
|
|
|
python setupall.py --daemon
|
|
|
|
python setupall.py --client-bitcoin
|
|
|
|
deactivate
|
|
|
|
|
2019-11-23 04:27:35 +00:00
|
|
|
echo $JOINMARKET_VERSION > $JOINMARKET_VERSION_FILE
|
2019-11-21 02:02:33 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-07-28 22:41:37 +00:00
|
|
|
# Upgrade RTL
|
2019-10-11 00:24:52 +00:00
|
|
|
RTL_UPGRADE_URL=https://github.com/ShahanaFarooqui/RTL/archive/v0.5.1.tar.gz
|
2019-07-28 22:41:37 +00:00
|
|
|
RTL_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.rtl_url
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $RTL_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $RTL_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$RTL_UPGRADE_URL" ]; then
|
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf RTL
|
|
|
|
sudo -u bitcoin wget $RTL_UPGRADE_URL -O RTL.tar.gz
|
|
|
|
sudo -u bitcoin tar -xvf RTL.tar.gz
|
|
|
|
sudo -u bitcoin rm RTL.tar.gz
|
|
|
|
sudo -u bitcoin mv RTL-* RTL
|
|
|
|
cd RTL
|
2019-08-15 02:41:38 +00:00
|
|
|
sudo -u bitcoin NG_CLI_ANALYTICS=false npm install
|
2019-07-28 22:41:37 +00:00
|
|
|
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
|
|
|
echo $RTL_UPGRADE_URL > $RTL_UPGRADE_URL_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Upgrade Bitcoin RPC Explorer
|
2019-10-05 01:30:56 +00:00
|
|
|
BTCRPCEXPLORER_UPGRADE_URL=https://github.com/janoside/btc-rpc-explorer/archive/v1.1.1.tar.gz
|
2019-07-28 22:41:37 +00:00
|
|
|
BTCRPCEXPLORER_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.btcrpcexplorer_url
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $BTCRPCEXPLORER_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $BTCRPCEXPLORER_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$BTCRPCEXPLORER_UPGRADE_URL" ]; then
|
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf btc-rpc-explorer
|
|
|
|
sudo -u bitcoin wget $BTCRPCEXPLORER_UPGRADE_URL -O btc-rpc-explorer.tar.gz
|
|
|
|
sudo -u bitcoin tar -xvf btc-rpc-explorer.tar.gz
|
|
|
|
sudo -u bitcoin rm btc-rpc-explorer.tar.gz
|
|
|
|
sudo -u bitcoin mv btc-rpc-* btc-rpc-explorer
|
|
|
|
cd btc-rpc-explorer
|
|
|
|
sudo -u bitcoin npm install
|
|
|
|
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
|
|
|
echo $BTCRPCEXPLORER_UPGRADE_URL > $BTCRPCEXPLORER_UPGRADE_URL_FILE
|
|
|
|
fi
|
|
|
|
|
2019-11-23 04:27:35 +00:00
|
|
|
# Upgrade WebSSH2
|
|
|
|
WEBSSH2_UPGRADE_URL=https://github.com/billchurch/webssh2/archive/v0.2.10-0.tar.gz
|
|
|
|
WEBSSH2_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.webssh2_url
|
|
|
|
CURRENT=""
|
2019-11-25 03:45:24 +00:00
|
|
|
if [ -f $WEBSSH2_UPGRADE_URL_FILE ]; then
|
2019-11-23 04:27:35 +00:00
|
|
|
CURRENT=$(cat $WEBSSH2_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$WEBSSH2_UPGRADE_URL" ]; then
|
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf webssh2
|
|
|
|
wget $WEBSSH2_UPGRADE_URL -O webssh2.tar.gz
|
|
|
|
tar -xvf webssh2.tar.gz
|
|
|
|
rm webssh2.tar.gz
|
|
|
|
mv webssh2-* webssh2
|
|
|
|
cd webssh2
|
|
|
|
mv app/config.json.sample app/config.json
|
|
|
|
docker build -t webssh2 .
|
|
|
|
|
|
|
|
echo $WEBSSH2_UPGRADE_URL > $WEBSSH2_UPGRADE_URL_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-10-10 02:50:07 +00:00
|
|
|
# Install ngrok for debugging
|
|
|
|
if [ ! -f /usr/bin/ngrok ]; then
|
|
|
|
cd /tmp
|
2019-10-11 00:24:52 +00:00
|
|
|
rm -rf /tmp/ngrok*
|
2019-10-10 02:50:07 +00:00
|
|
|
NGROK_URL=https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
|
|
|
|
if [ $IS_X86 = 1 ]; then
|
|
|
|
NGROK_URL=https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip
|
|
|
|
fi
|
|
|
|
wget $NGROK_URL
|
|
|
|
unzip ngrok-*.zip
|
|
|
|
cp ngrok /usr/bin/
|
|
|
|
fi
|
2019-07-28 22:41:37 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Enable any new/required services
|
2019-09-16 23:46:20 +00:00
|
|
|
systemctl enable firewall
|
2019-09-24 01:50:19 +00:00
|
|
|
systemctl enable invalid_block_check
|
2019-10-14 01:47:14 +00:00
|
|
|
systemctl enable usb_driver_check
|
2019-10-20 04:02:50 +00:00
|
|
|
systemctl enable https
|
2019-11-12 02:35:05 +00:00
|
|
|
systemctl enable glances
|
2019-11-14 02:32:37 +00:00
|
|
|
systemctl enable netdata
|
2019-11-23 04:27:35 +00:00
|
|
|
systemctl enable webssh2
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-09-17 03:23:34 +00:00
|
|
|
# Disable any old services
|
|
|
|
sudo systemctl disable hitch
|
|
|
|
sudo systemctl disable mongodb
|
2019-11-09 16:14:56 +00:00
|
|
|
sudo systemctl disable lnd_admin
|
2019-09-17 03:23:34 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Reload service settings
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
|
|
|
# Sync FS
|
2019-11-27 00:19:33 +00:00
|
|
|
sync
|