2019-07-13 18:25:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
###
|
2019-07-13 02:02:28 +00:00
|
|
|
### Setup myNode (all devices)
|
2019-06-26 04:15:07 +00:00
|
|
|
### Run with "sudo"
|
|
|
|
###
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$#" != "1" ]; then
|
|
|
|
echo "Usage: $0 <ip address>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
SERVER_IP=$1
|
|
|
|
|
2019-06-30 21:13:04 +00:00
|
|
|
# Determine Device
|
2019-12-22 01:55:42 +00:00
|
|
|
IS_ARMBIAN=0
|
2019-06-30 21:13:04 +00:00
|
|
|
IS_ROCK64=0
|
2019-12-06 03:30:23 +00:00
|
|
|
IS_ROCKPRO64=0
|
|
|
|
IS_RASPI=0
|
2019-06-30 21:13:04 +00:00
|
|
|
IS_RASPI3=0
|
|
|
|
IS_RASPI4=0
|
2019-10-03 03:10:20 +00:00
|
|
|
IS_X86=0
|
2019-12-06 03:30:23 +00:00
|
|
|
IS_UNKNOWN=0
|
|
|
|
DEVICE_TYPE="unknown"
|
|
|
|
MODEL=$(cat /proc/device-tree/model) || IS_UNKNOWN=1
|
2019-10-03 03:10:20 +00:00
|
|
|
uname -a | grep amd64 && IS_X86=1 || true
|
2019-12-22 01:55:42 +00:00
|
|
|
if [[ $MODEL == *"Rock64"* ]]; then
|
|
|
|
IS_ARMBIAN=1
|
2019-12-06 03:30:23 +00:00
|
|
|
IS_ROCK64=1
|
2019-12-22 01:55:42 +00:00
|
|
|
elif [[ $MODEL == *"RockPro64"* ]]; then
|
|
|
|
IS_ARMBIAN=1
|
2019-12-06 03:30:23 +00:00
|
|
|
IS_ROCKPRO64=1
|
|
|
|
elif [[ $MODEL == *"Raspberry Pi 3"* ]]; then
|
|
|
|
IS_RASPI=1
|
|
|
|
IS_RASPI3=1
|
|
|
|
elif [[ $MODEL == *"Raspberry Pi 4"* ]]; then
|
|
|
|
IS_RASPI=1
|
|
|
|
IS_RASPI4=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $IS_UNKNOWN = 1 ]; then
|
|
|
|
echo "UNKNOWN DEVICE TYPE"
|
|
|
|
exit 1
|
2019-10-03 03:10:20 +00:00
|
|
|
fi
|
2019-06-30 21:13:04 +00:00
|
|
|
|
2019-12-06 03:30:23 +00:00
|
|
|
|
2019-12-22 01:55:42 +00:00
|
|
|
# Make sure FS is expanded for armbian
|
|
|
|
if [ $IS_ARMBIAN = 1 ] ; then
|
2019-07-06 01:45:42 +00:00
|
|
|
/usr/lib/armbian/armbian-resize-filesystem start
|
|
|
|
fi
|
|
|
|
|
2019-10-12 02:31:31 +00:00
|
|
|
|
|
|
|
# Download rootfs
|
|
|
|
rm -rf /tmp/rootfs.tar.gz
|
|
|
|
rm -rf /tmp/upgrade/
|
|
|
|
mkdir -p /tmp/upgrade
|
|
|
|
|
|
|
|
TARBALL=""
|
|
|
|
if [ $IS_ROCK64 = 1 ]; then
|
|
|
|
TARBALL="mynode_rootfs_rock64.tar.gz"
|
2019-12-06 03:30:23 +00:00
|
|
|
elif [ $IS_ROCKPRO64 = 1 ]; then
|
|
|
|
TARBALL="mynode_rootfs_rockpro64.tar.gz"
|
2019-10-12 02:31:31 +00:00
|
|
|
elif [ $IS_RASPI3 = 1 ]; then
|
|
|
|
TARBALL="mynode_rootfs_raspi3.tar.gz"
|
|
|
|
elif [ $IS_RASPI4 = 1 ]; then
|
|
|
|
TARBALL="mynode_rootfs_raspi4.tar.gz"
|
|
|
|
elif [ $IS_X86 = 1 ]; then
|
|
|
|
TARBALL="mynode_rootfs_debian.tar.gz"
|
|
|
|
fi
|
|
|
|
wget http://${SERVER_IP}:8000/${TARBALL} -O /tmp/rootfs.tar.gz
|
|
|
|
|
|
|
|
|
2019-07-13 18:25:22 +00:00
|
|
|
# Add sources
|
2019-07-13 21:46:58 +00:00
|
|
|
|
2019-07-13 18:25:22 +00:00
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
# Update OS
|
2019-07-13 18:25:22 +00:00
|
|
|
apt -y update # Needed to accept new repos
|
|
|
|
apt-get -y update
|
2019-06-26 04:15:07 +00:00
|
|
|
apt-get -y upgrade
|
|
|
|
|
|
|
|
# Install other tools (run section multiple times to make sure success)
|
2019-11-26 00:13:33 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2019-06-26 04:15:07 +00:00
|
|
|
apt-get -y install htop git curl bash-completion jq dphys-swapfile lsof libzmq3-dev
|
|
|
|
apt-get -y install build-essential python-dev python-pip python3-dev python3-pip
|
|
|
|
apt-get -y install transmission-cli fail2ban ufw tclsh bluez python-bluez redis-server
|
2019-07-13 18:25:22 +00:00
|
|
|
#apt-get -y install mongodb-org
|
|
|
|
apt-get -y install clang hitch zlib1g-dev libffi-dev file toilet ncdu
|
2019-06-26 04:15:07 +00:00
|
|
|
apt-get -y install toilet-fonts avahi-daemon figlet libsecp256k1-dev
|
2019-11-29 22:36:29 +00:00
|
|
|
apt-get -y install inotify-tools libssl-dev tor tmux screen fonts-dejavu
|
2019-08-08 01:46:58 +00:00
|
|
|
apt-get -y install python-grpcio python3-grpcio
|
2019-10-26 04:42:32 +00:00
|
|
|
apt-get -y install pv sysstat network-manager rsync parted unzip pkg-config
|
2019-11-29 21:55:55 +00:00
|
|
|
apt-get -y install libfreetype6-dev libpng-dev libatlas-base-dev libgmp-dev libltdl-dev
|
|
|
|
apt-get -y install libffi-dev libssl-dev glances python3-bottle automake libtool libltdl7
|
2019-11-18 03:58:37 +00:00
|
|
|
apt -y -qq install apt-transport-https ca-certificates
|
2019-12-28 22:20:15 +00:00
|
|
|
apt-get -y install xorg chromium openbox lightdm openjdk-11-jre
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
2019-11-26 13:49:24 +00:00
|
|
|
# Make sure some software is removed
|
|
|
|
apt-get -y purge ntp # (conflicts with systemd-timedatectl)
|
2019-12-19 03:34:57 +00:00
|
|
|
apt-get -y purge chrony # (conflicts with systemd-timedatectl)
|
2019-11-26 13:49:24 +00:00
|
|
|
|
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
# Install other things without recommendation
|
|
|
|
apt-get -y install --no-install-recommends expect
|
|
|
|
|
|
|
|
# Add bitcoin users
|
2019-06-30 21:13:04 +00:00
|
|
|
useradd -m -s /bin/bash bitcoin || true
|
2019-06-29 15:53:33 +00:00
|
|
|
usermod -a -G debian-tor bitcoin
|
2019-06-26 04:15:07 +00:00
|
|
|
|
2019-07-02 03:25:05 +00:00
|
|
|
|
|
|
|
# Install pip packages
|
2019-06-26 04:15:07 +00:00
|
|
|
pip install setuptools
|
2019-07-02 03:25:05 +00:00
|
|
|
pip install --upgrade setuptools
|
2019-06-26 04:15:07 +00:00
|
|
|
pip install wheel
|
2019-07-02 03:25:05 +00:00
|
|
|
pip install --upgrade wheel
|
2019-06-26 04:15:07 +00:00
|
|
|
pip install speedtest-cli transmissionrpc flask python-bitcoinrpc redis prometheus_client requests
|
|
|
|
pip install python-pam python-bitcoinlib psutil
|
|
|
|
pip install grpcio grpcio-tools googleapis-common-protos
|
2019-11-21 02:02:33 +00:00
|
|
|
pip install tzupdate virtualenv
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
2019-10-16 02:10:40 +00:00
|
|
|
# Import Keys
|
|
|
|
curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import
|
|
|
|
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964
|
|
|
|
|
|
|
|
|
2019-07-13 18:25:22 +00:00
|
|
|
# Update python3 to 3.7.X
|
2019-06-27 03:02:08 +00:00
|
|
|
PYTHON3_VERSION=$(python3 --version)
|
2019-07-13 18:25:22 +00:00
|
|
|
if [[ "$PYTHON3_VERSION" != *"Python 3.7"* ]]; then
|
2019-06-27 03:02:08 +00:00
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
|
|
|
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
|
|
|
|
tar xf Python-3.7.2.tar.xz
|
|
|
|
cd Python-3.7.2
|
|
|
|
./configure
|
|
|
|
make -j4
|
|
|
|
sudo make install
|
|
|
|
cd ~
|
|
|
|
else
|
|
|
|
echo "Python up to date"
|
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Install python3 specific tools (run multiple times to make sure success)
|
|
|
|
pip3 install wheel setuptools
|
|
|
|
pip3 install bitstring lnd-grpc pycoin aiohttp connectrum python-bitcoinlib
|
2019-08-18 03:30:21 +00:00
|
|
|
pip3 install python-bitcointx
|
2019-12-09 05:02:38 +00:00
|
|
|
pip3 install lndmanage==0.8.0.1 # Install LND Manage (keep up to date with LND)
|
2019-11-11 03:22:39 +00:00
|
|
|
pip3 install docker-compose
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
2019-06-27 03:02:08 +00:00
|
|
|
# Install Rust
|
2019-06-30 21:13:04 +00:00
|
|
|
if [ ! -f /tmp/installed_rust ]; then
|
|
|
|
wget https://sh.rustup.rs -O /tmp/setup_rust.sh
|
|
|
|
/bin/bash /tmp/setup_rust.sh -y
|
|
|
|
touch /tmp/installed_rust
|
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
# Install node
|
2019-06-30 21:13:04 +00:00
|
|
|
if [ ! -f /tmp/installed_node ]; then
|
|
|
|
curl -sL https://deb.nodesource.com/setup_11.x | bash -
|
|
|
|
apt-get install -y nodejs
|
|
|
|
touch /tmp/installed_node
|
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
2019-11-11 03:22:39 +00:00
|
|
|
# Install docker
|
2019-11-19 03:18:56 +00:00
|
|
|
curl -sSL https://get.docker.com | sed 's/sleep 20/sleep 1/' | sudo sh
|
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-26 04:15:07 +00:00
|
|
|
# Install node packages
|
|
|
|
npm install -g pug-cli browserify uglify-js babel-cli
|
|
|
|
|
|
|
|
# Remove existing MOTD login info
|
|
|
|
rm -rf /etc/motd
|
|
|
|
rm -rf /etc/update-motd.d/*
|
|
|
|
|
|
|
|
|
|
|
|
#########################################################
|
|
|
|
|
|
|
|
|
|
|
|
# Install Bitcoin
|
2019-11-27 02:19:45 +00:00
|
|
|
BTC_VERSION="0.19.0.1"
|
2019-12-07 02:41:55 +00:00
|
|
|
ARCH="UNKNOWN"
|
2019-12-22 01:55:42 +00:00
|
|
|
if [ $IS_RASPI = 1 ]; then
|
2019-12-07 02:41:55 +00:00
|
|
|
ARCH="arm-linux-gnueabihf"
|
|
|
|
elif [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ]; then
|
2019-06-26 04:15:07 +00:00
|
|
|
ARCH="aarch64-linux-gnu"
|
2019-12-07 02:41:55 +00:00
|
|
|
elif [ $IS_X86 = 1 ]; then
|
2019-10-03 03:10:20 +00:00
|
|
|
ARCH="x86_64-linux-gnu"
|
2019-12-07 02:41:55 +00:00
|
|
|
else
|
|
|
|
echo "Unknown Bitcoin Version"
|
|
|
|
exit 1
|
2019-10-03 03:10:20 +00:00
|
|
|
fi
|
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-26 04:15:07 +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-27 03:02:08 +00:00
|
|
|
CURRENT=""
|
|
|
|
if [ -f $BTC_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $BTC_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$BTC_UPGRADE_URL" ]; then
|
2019-10-16 02:57:46 +00:00
|
|
|
# Download and install Bitcoin
|
2019-06-27 03:02:08 +00:00
|
|
|
rm -rf /tmp/download
|
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
|
|
|
|
2019-10-16 03:03:53 +00:00
|
|
|
wget $BTC_UPGRADE_URL
|
2019-10-16 02:57:46 +00:00
|
|
|
wget $BTC_UPGRADE_SHA256SUM_URL -O SHA256SUMS.asc
|
|
|
|
|
|
|
|
sha256sum --ignore-missing --check SHA256SUMS.asc
|
2019-10-16 03:03:53 +00:00
|
|
|
gpg --verify SHA256SUMS.asc
|
2019-10-16 02:57:46 +00:00
|
|
|
|
2019-10-16 03:19:02 +00:00
|
|
|
# Install Bitcoin
|
|
|
|
tar -xvf bitcoin-$BTC_VERSION-$ARCH.tar.gz
|
|
|
|
mv bitcoin-$BTC_VERSION bitcoin
|
2019-06-27 03:02:08 +00:00
|
|
|
install -m 0755 -o root -g root -t /usr/local/bin bitcoin/bin/*
|
2019-10-03 03:10:20 +00:00
|
|
|
if [ ! -L /home/bitcoin/.bitcoin ]; then
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/bitcoin /home/bitcoin/.bitcoin
|
|
|
|
fi
|
|
|
|
if [ ! -L /home/bitcoin/.lnd ]; then
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/lnd /home/bitcoin/.lnd
|
|
|
|
fi
|
|
|
|
mkdir -p /home/admin/.bitcoin
|
2019-06-27 03:02:08 +00:00
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
2019-06-30 21:13:04 +00:00
|
|
|
echo $BTC_UPGRADE_URL > $BTC_UPGRADE_URL_FILE
|
2019-06-27 03:02:08 +00:00
|
|
|
fi
|
|
|
|
cd ~
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
# Install Lightning
|
2019-12-13 00:23:25 +00:00
|
|
|
LND_VERSION="v0.8.2-beta"
|
2019-10-16 02:10:40 +00:00
|
|
|
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-26 04:15:07 +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-27 03:02:08 +00:00
|
|
|
CURRENT=""
|
|
|
|
if [ -f $LND_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $LND_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$LND_UPGRADE_URL" ]; then
|
|
|
|
rm -rf /tmp/download
|
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
|
|
|
|
2019-10-16 03:03:53 +00:00
|
|
|
wget $LND_UPGRADE_URL
|
|
|
|
wget $LND_UPGRADE_MANIFEST_URL
|
|
|
|
wget $LND_UPGRADE_MANIFEST_SIG_URL
|
2019-10-16 02:10:40 +00:00
|
|
|
|
2019-10-16 03:03:53 +00:00
|
|
|
gpg --verify manifest-*.txt.sig
|
2019-10-16 02:10:40 +00:00
|
|
|
|
2019-10-16 03:03:53 +00:00
|
|
|
tar -xzf lnd-*.tar.gz
|
|
|
|
mv $LND_ARCH-$LND_VERSION lnd
|
2019-06-27 03:02:08 +00:00
|
|
|
install -m 0755 -o root -g root -t /usr/local/bin lnd/*
|
2019-10-03 03:10:20 +00:00
|
|
|
ln -s /bin/ip /usr/bin/ip || true
|
2019-06-27 03:02:08 +00:00
|
|
|
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
2019-06-30 21:13:04 +00:00
|
|
|
echo $LND_UPGRADE_URL > $LND_UPGRADE_URL_FILE
|
2019-06-27 03:02:08 +00:00
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
cd ~
|
|
|
|
|
|
|
|
# Setup "install" location for some apps
|
|
|
|
mkdir -p /opt/mynode
|
|
|
|
chown -R bitcoin:bitcoin /opt/mynode
|
|
|
|
|
|
|
|
|
|
|
|
# Install LND Hub
|
2019-06-30 21:13:04 +00:00
|
|
|
if [ ! -f /tmp/installed_lndhub ]; then
|
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf LndHub
|
|
|
|
sudo -u bitcoin git clone https://github.com/BlueWallet/LndHub.git
|
|
|
|
cd LndHub
|
2019-11-29 21:55:55 +00:00
|
|
|
sudo -u bitcoin npm install --only=production
|
2019-06-30 21:13:04 +00:00
|
|
|
sudo -u bitcoin ln -s /home/bitcoin/.lnd/tls.cert tls.cert
|
|
|
|
sudo -u bitcoin ln -s /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon admin.macaroon
|
|
|
|
touch /tmp/installed_lndhub
|
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
2019-06-27 03:02:08 +00:00
|
|
|
# Install electrs (only build to save new version, now included in overlay)
|
2019-06-26 04:15:07 +00:00
|
|
|
#cd /home/admin/download
|
|
|
|
#wget https://github.com/romanz/electrs/archive/v0.7.0.tar.gz
|
|
|
|
#tar -xvf v0.7.0.tar.gz
|
|
|
|
#cd electrs-0.7.0
|
|
|
|
#cargo build --release
|
|
|
|
#sudo install -g root -o root target/release/electrs /usr/bin/electrs
|
|
|
|
#cd ~
|
|
|
|
|
|
|
|
|
2019-12-23 05:46:42 +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
|
|
|
|
|
|
|
|
|
2019-12-26 05:11:29 +00:00
|
|
|
# Install Whirlpool
|
2020-01-07 05:23:21 +00:00
|
|
|
WHIRLPOOL_UPGRADE_URL=https://github.com/Samourai-Wallet/whirlpool-client-cli/releases/download/0.10.1/whirlpool-client-cli-0.10.1-run.jar
|
2019-12-26 05:11:29 +00:00
|
|
|
WHIRLPOOL_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.whirlpool_url
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $WHIRLPOOL_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $WHIRLPOOL_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$WHIRLPOOL_UPGRADE_URL" ]; then
|
|
|
|
sudo -u bitcoin mkdir -p /opt/mynode/whirlpool
|
|
|
|
cd /opt/mynode/whirlpool
|
|
|
|
sudo rm -rf *.jar
|
|
|
|
sudo -u bitcoin wget -O whirlpool.jar $WHIRLPOOL_UPGRADE_URL
|
|
|
|
|
|
|
|
echo $WHIRLPOOL_UPGRADE_URL > $WHIRLPOOL_UPGRADE_URL_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
# Install RTL
|
2019-12-05 04:28:56 +00:00
|
|
|
RTL_UPGRADE_URL=https://github.com/Ride-The-Lightning/RTL/archive/v0.5.4.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
|
2019-06-30 21:13:04 +00:00
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf RTL
|
2019-07-28 22:41:37 +00:00
|
|
|
sudo -u bitcoin wget $RTL_UPGRADE_URL -O RTL.tar.gz
|
2019-06-30 21:13:04 +00:00
|
|
|
sudo -u bitcoin tar -xvf RTL.tar.gz
|
|
|
|
sudo -u bitcoin rm RTL.tar.gz
|
|
|
|
sudo -u bitcoin mv RTL-* RTL
|
|
|
|
cd RTL
|
2019-11-29 21:55:55 +00:00
|
|
|
sudo -u bitcoin NG_CLI_ANALYTICS=false npm install --only=production
|
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
|
2019-06-30 21:13:04 +00:00
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Install Bitcoin RPC Explorer
|
2019-12-25 04:03:43 +00:00
|
|
|
BTCRPCEXPLORER_UPGRADE_URL=https://github.com/janoside/btc-rpc-explorer/archive/v1.1.5.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
|
2019-06-30 21:13:04 +00:00
|
|
|
cd /opt/mynode
|
|
|
|
rm -rf btc-rpc-explorer
|
2019-07-28 22:41:37 +00:00
|
|
|
sudo -u bitcoin wget $BTCRPCEXPLORER_UPGRADE_URL -O btc-rpc-explorer.tar.gz
|
2019-06-30 21:13:04 +00:00
|
|
|
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
|
2019-11-29 21:55:55 +00:00
|
|
|
sudo -u bitcoin npm install --only=production
|
2019-07-28 22:41:37 +00:00
|
|
|
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
|
|
|
echo $BTCRPCEXPLORER_UPGRADE_URL > $BTCRPCEXPLORER_UPGRADE_URL_FILE
|
2019-06-30 21:13:04 +00:00
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Install LND Connect
|
2019-10-03 03:10:20 +00:00
|
|
|
LNDCONNECTARCH="lndconnect-linux-armv7"
|
|
|
|
if [ $IS_X86 = 1 ]; then
|
|
|
|
LNDCONNECTARCH="lndconnect-linux-amd64"
|
|
|
|
fi
|
2019-12-07 03:28:53 +00:00
|
|
|
LNDCONNECT_UPGRADE_URL=https://github.com/LN-Zap/lndconnect/releases/download/v0.2.0/$LNDCONNECTARCH-v0.2.0.tar.gz
|
2019-07-28 22:41:37 +00:00
|
|
|
LNDCONNECT_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lndconnect_url
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $LNDCONNECT_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $LNDCONNECT_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$LNDCONNECT_UPGRADE_URL" ]; then
|
2019-06-30 21:13:04 +00:00
|
|
|
rm -rf /tmp/download
|
|
|
|
mkdir -p /tmp/download
|
|
|
|
cd /tmp/download
|
2019-07-28 22:41:37 +00:00
|
|
|
wget $LNDCONNECT_UPGRADE_URL -O lndconnect.tar.gz
|
2019-06-30 21:13:04 +00:00
|
|
|
tar -xvf lndconnect.tar.gz
|
|
|
|
rm lndconnect.tar.gz
|
|
|
|
mv lndconnect-* lndconnect
|
|
|
|
install -m 0755 -o root -g root -t /usr/local/bin lndconnect/*
|
2019-07-28 22:41:37 +00:00
|
|
|
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
|
|
|
|
echo $LNDCONNECT_UPGRADE_URL > $LNDCONNECT_UPGRADE_URL_FILE
|
2019-06-30 21:13:04 +00:00
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
|
2019-10-10 02:50:07 +00:00
|
|
|
|
|
|
|
# Install ngrok for debugging
|
|
|
|
if [ ! -f /usr/bin/ngrok ]; then
|
|
|
|
cd /tmp
|
|
|
|
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-06-26 04:15:07 +00:00
|
|
|
#########################################################
|
|
|
|
|
|
|
|
|
2019-10-12 02:31:31 +00:00
|
|
|
# Copy myNode rootfs (downlaoded earlier)
|
2019-06-26 04:15:07 +00:00
|
|
|
tar -xvf /tmp/rootfs.tar.gz -C /tmp/upgrade/
|
|
|
|
|
|
|
|
# Install files
|
2019-10-03 03:10:20 +00:00
|
|
|
if [ $IS_X86 = 1 ]; then
|
|
|
|
rsync -r -K /tmp/upgrade/out/rootfs_*/* /
|
|
|
|
else
|
|
|
|
cp -rf /tmp/upgrade/out/rootfs_*/* /
|
|
|
|
fi
|
2019-06-26 04:15:07 +00:00
|
|
|
sleep 1
|
|
|
|
sync
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
|
|
# Setup myNode Startup Script
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl enable mynode
|
|
|
|
systemctl enable quicksync
|
|
|
|
systemctl enable torrent_check
|
|
|
|
systemctl enable firewall
|
|
|
|
systemctl enable bandwidth
|
|
|
|
systemctl enable www
|
|
|
|
systemctl enable drive_check
|
|
|
|
systemctl enable bitcoind
|
|
|
|
systemctl enable lnd
|
|
|
|
systemctl enable lnd_unlock
|
|
|
|
systemctl enable lnd_backup
|
|
|
|
systemctl enable lnd_admin_files
|
|
|
|
systemctl enable lndconnect
|
|
|
|
systemctl enable redis-server
|
2019-11-30 17:40:59 +00:00
|
|
|
#systemctl enable mongodb
|
2019-06-26 04:15:07 +00:00
|
|
|
#systemctl enable electrs # DISABLED BY DEFAULT
|
|
|
|
#systemctl enable lndhub # DISABLED BY DEFAULT
|
|
|
|
#systemctl enable btc_rpc_explorer # DISABLED BY DEFAULT
|
|
|
|
systemctl enable tls_proxy
|
2019-10-20 04:02:50 +00:00
|
|
|
systemctl enable https
|
2019-06-26 04:15:07 +00:00
|
|
|
systemctl enable rtl
|
2019-11-09 16:14:56 +00:00
|
|
|
#systemctl enable lnd_admin # REMOVED
|
2019-06-29 15:53:33 +00:00
|
|
|
systemctl enable tor
|
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-11-30 03:29:55 +00:00
|
|
|
systemctl enable docker_images
|
2019-11-12 02:35:05 +00:00
|
|
|
systemctl enable glances
|
2019-11-29 22:08:54 +00:00
|
|
|
systemctl enable netdata
|
|
|
|
systemctl enable webssh2
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
|
2019-12-09 03:46:22 +00:00
|
|
|
# Regenerate MAC Address for Armbian devices
|
2019-12-22 01:55:42 +00:00
|
|
|
if [ $IS_ARMBIAN = 1 ]; then
|
2019-09-28 02:00:48 +00:00
|
|
|
. /usr/lib/armbian/armbian-common
|
2019-12-22 01:55:42 +00:00
|
|
|
CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | grep ethernet | tail -n1)"
|
2019-09-28 02:00:48 +00:00
|
|
|
UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}")
|
|
|
|
get_random_mac
|
|
|
|
nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR
|
|
|
|
nmcli connection modify $UUID -ethernet.mac-address ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-12-09 03:46:22 +00:00
|
|
|
# Disable services
|
2019-12-22 01:55:42 +00:00
|
|
|
systemctl disable hitch
|
|
|
|
systemctl disable mongodb
|
|
|
|
systemctl disable lnd_admin
|
|
|
|
systemctl disable dhcpcd || true
|
2019-12-09 03:46:22 +00:00
|
|
|
|
2019-09-28 02:00:48 +00:00
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
# Delete junk
|
|
|
|
rm -rf /home/admin/download
|
|
|
|
rm -rf /home/admin/.bash_history
|
|
|
|
rm -rf /home/bitcoin/.bash_history
|
|
|
|
rm -rf /root/.bash_history
|
|
|
|
rm -rf /root/.ssh/known_hosts
|
|
|
|
rm -rf /etc/resolv.conf
|
|
|
|
rm -rf /tmp/*
|
2019-07-03 02:13:08 +00:00
|
|
|
rm -rf ~/setup_device.sh
|
2019-07-06 01:45:42 +00:00
|
|
|
rm -rf /etc/motd # Remove simple motd for update-motd.d
|
2019-06-26 04:15:07 +00:00
|
|
|
|
|
|
|
sync
|
|
|
|
|
2019-06-30 21:13:04 +00:00
|
|
|
set +x
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo "##################################"
|
|
|
|
echo " SETUP COMPLETE "
|
|
|
|
echo " Reboot your device to begin! "
|
|
|
|
echo "##################################"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
2019-06-26 04:15:07 +00:00
|
|
|
### MAKE IMAGE NOW ###
|
|
|
|
# This prevents auto gen files like certs to be part of the base image
|
|
|
|
# Must make sure image can boot after this point and fully come up
|
|
|
|
|
|
|
|
|