2019-11-30 03:29:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-25 04:46:22 +00:00
|
|
|
# set -e # Stop on error (skip for now with new logic to allow an attempt to install each container)
|
2020-04-08 04:31:06 +00:00
|
|
|
set -x
|
2019-11-30 03:29:55 +00:00
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2020-01-07 05:18:00 +00:00
|
|
|
echo "Starting mynode_docker_images.sh ..."
|
2020-03-01 20:53:50 +00:00
|
|
|
touch /tmp/installing_docker_images
|
2020-01-07 05:18:00 +00:00
|
|
|
|
2019-11-30 03:29:55 +00:00
|
|
|
# Drive should be mounted, let's still wait a bit
|
2020-03-01 18:40:59 +00:00
|
|
|
sleep 10s
|
2019-11-30 03:29:55 +00:00
|
|
|
|
2020-01-15 04:38:03 +00:00
|
|
|
echo "Waiting on bitcoin to sync so drive usage is lower..."
|
|
|
|
/usr/bin/wait_on_bitcoin.sh
|
|
|
|
|
2020-02-23 21:55:37 +00:00
|
|
|
while true; do
|
|
|
|
echo "Checking for building new docker images..."
|
|
|
|
touch /tmp/installing_docker_images
|
|
|
|
|
|
|
|
# Pull images that don't need to be built
|
2020-03-21 02:53:38 +00:00
|
|
|
# ???
|
2020-02-23 21:55:37 +00:00
|
|
|
|
|
|
|
# Upgrade WebSSH2
|
|
|
|
echo "Checking for new webssh2..."
|
2020-09-03 02:24:40 +00:00
|
|
|
WEBSSH2_UPGRADE_VERSION=v0.2.10-0
|
|
|
|
WEBSSH2_UPGRADE_URL=https://github.com/billchurch/webssh2/archive/${WEBSSH2_UPGRADE_VERSION}.tar.gz
|
2020-02-23 21:55:37 +00:00
|
|
|
WEBSSH2_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/webssh2_url
|
|
|
|
CURRENT=""
|
|
|
|
if [ -f $WEBSSH2_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $WEBSSH2_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$WEBSSH2_UPGRADE_URL" ]; then
|
|
|
|
docker rmi webssh2 || true
|
|
|
|
|
|
|
|
cd /tmp/
|
|
|
|
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
|
|
|
|
docker build -t webssh2 .
|
2021-01-25 04:46:22 +00:00
|
|
|
if [ $? == 0 ]; then
|
|
|
|
echo $WEBSSH2_UPGRADE_URL > $WEBSSH2_UPGRADE_URL_FILE
|
|
|
|
fi
|
2020-02-23 21:55:37 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-21 02:56:53 +00:00
|
|
|
# Upgrade mempool
|
|
|
|
echo "Checking for new mempool..."
|
2021-02-23 02:39:14 +00:00
|
|
|
MEMPOOL_UPGRADE_VERSION=v2.1.2
|
|
|
|
MEMPOOL_UPGRADE_URL=https://github.com/mempool/mempool/archive/${MEMPOOL_UPGRADE_VERSION}.tar.gz
|
|
|
|
MEMPOOL_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/mempoolspace_url
|
2020-02-23 21:55:37 +00:00
|
|
|
CURRENT=""
|
2021-02-23 02:39:14 +00:00
|
|
|
if [ -f $MEMPOOL_UPGRADE_URL_FILE ]; then
|
|
|
|
CURRENT=$(cat $MEMPOOL_UPGRADE_URL_FILE)
|
2020-02-23 21:55:37 +00:00
|
|
|
fi
|
2021-02-23 02:39:14 +00:00
|
|
|
if [ "$CURRENT" != "$MEMPOOL_UPGRADE_URL" ]; then
|
|
|
|
docker rmi mempoolspace || true # Remove old v1 image
|
|
|
|
|
|
|
|
cd /mnt/hdd/mynode/mempool
|
|
|
|
mkdir -p data mysql/data mysql/db-scripts
|
|
|
|
cp -f /usr/share/mynode/mempool-docker-compose.yml /mnt/hdd/mynode/docker-compose.yml
|
|
|
|
|
|
|
|
rm -rf /opt/download/mempool
|
|
|
|
mkdir -p /opt/download/mempool
|
|
|
|
cd /opt/download/mempool
|
|
|
|
wget $MEMPOOL_UPGRADE_URL -O mempool.tar.gz
|
|
|
|
tar -xvf mempool.tar.gz
|
|
|
|
rm mempool.tar.gz
|
|
|
|
mv mempool-* mempool
|
|
|
|
cp -f mempool/mariadb-structure.sql /mnt/hdd/mynode/mempool/mysql/db-scripts/mariadb-structure.sql
|
|
|
|
|
|
|
|
# Update env variable to use latest version
|
|
|
|
sed -i "s/VERSION=.*/VERSION=$MEMPOOL_UPGRADE_VERSION/g" /mnt/hdd/mynode/mempool/.env
|
|
|
|
|
|
|
|
docker pull mempool/frontend:${MEMPOOL_UPGRADE_VERSION}
|
|
|
|
docker pull mempool/backend:${MEMPOOL_UPGRADE_VERSION}
|
|
|
|
|
|
|
|
enabled=$(systemctl is-enabled mempoolspace)
|
|
|
|
if [ "$enabled" = "enabled" ]; then
|
|
|
|
systemctl restart mempoolspace &
|
2021-01-25 04:46:22 +00:00
|
|
|
fi
|
2021-02-23 02:39:14 +00:00
|
|
|
|
|
|
|
echo $MEMPOOL_UPGRADE_URL > $MEMPOOL_UPGRADE_URL_FILE
|
2020-02-23 21:55:37 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-01 18:40:59 +00:00
|
|
|
# Install Dojo
|
2021-03-14 06:05:39 +00:00
|
|
|
DOJO_VERSION="v1.9.0"
|
|
|
|
DOJO_TAR_HASH="b9709c18bb58f514a2f1db948b421b691b22fbf7713f5a68ce9627f35fcbf306"
|
2020-09-25 17:20:35 +00:00
|
|
|
DOJO_UPGRADE_URL=https://code.samourai.io/dojo/samourai-dojo/-/archive/$DOJO_VERSION/samourai-dojo-$DOJO_VERSION.tar.gz
|
2020-03-01 18:40:59 +00:00
|
|
|
DOJO_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/dojo_url
|
|
|
|
CURRENT=""
|
|
|
|
INSTALL=true
|
2020-05-13 01:54:17 +00:00
|
|
|
# If Upgrade file existed, mark "install" choice for legacy devices
|
2020-03-01 18:40:59 +00:00
|
|
|
if [ -f $DOJO_UPGRADE_URL_FILE ]; then
|
2020-05-13 01:54:17 +00:00
|
|
|
touch /mnt/hdd/mynode/settings/mynode_dojo_install
|
|
|
|
sync
|
|
|
|
sleep 3s
|
2020-03-01 18:40:59 +00:00
|
|
|
fi
|
2021-03-14 06:05:39 +00:00
|
|
|
# Only install Dojo if marked for installation and testnet not enabled
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/mynode_dojo_install ] && [ ! -f $IS_TESTNET_ENABLED_FILE ]; then
|
2020-05-13 01:54:17 +00:00
|
|
|
if [ -f $DOJO_UPGRADE_URL_FILE ]; then
|
|
|
|
INSTALL=false
|
|
|
|
CURRENT=$(cat $DOJO_UPGRADE_URL_FILE)
|
|
|
|
fi
|
|
|
|
if [ "$CURRENT" != "$DOJO_UPGRADE_URL" ]; then
|
2021-01-25 04:46:22 +00:00
|
|
|
MARK_DOJO_COMPLETE=1
|
2021-01-23 04:55:44 +00:00
|
|
|
sudo mkdir -p /opt/download/dojo
|
|
|
|
sudo mkdir -p /mnt/hdd/mynode/dojo
|
|
|
|
sudo rm -rf /opt/download/dojo/*
|
|
|
|
cd /opt/download/dojo
|
2020-05-13 01:54:17 +00:00
|
|
|
sudo wget -O dojo.tar.gz $DOJO_UPGRADE_URL
|
2020-09-25 17:20:35 +00:00
|
|
|
|
|
|
|
# verify tar file
|
|
|
|
echo "$DOJO_TAR_HASH dojo.tar.gz" > /tmp/dojo_hash
|
|
|
|
sha256sum --check /tmp/dojo_hash
|
|
|
|
|
2020-05-13 01:54:17 +00:00
|
|
|
sudo tar -zxvf dojo.tar.gz
|
2021-01-23 04:55:44 +00:00
|
|
|
sudo cp -r samourai-dojo*/* /mnt/hdd/mynode/dojo
|
|
|
|
sudo rm -rf /opt/download/dojo/*
|
2020-05-13 01:54:17 +00:00
|
|
|
|
|
|
|
# Configure Dojo for MyNode
|
2021-01-25 04:46:22 +00:00
|
|
|
sudo /usr/bin/mynode_gen_dojo_config.sh || MARK_DOJO_COMPLETE=0
|
2020-05-13 01:54:17 +00:00
|
|
|
|
|
|
|
# Run Dojo Install or Upgrade
|
2021-01-23 04:55:44 +00:00
|
|
|
cd /mnt/hdd/mynode/dojo/docker/my-dojo
|
2020-09-26 01:28:16 +00:00
|
|
|
INSTALL_PID=0
|
2020-05-13 01:54:17 +00:00
|
|
|
if [ "$INSTALL" = "true" ]; then
|
|
|
|
yes | sudo ./dojo.sh install &
|
2020-09-26 01:28:16 +00:00
|
|
|
INSTALL_PID=$!
|
2020-05-13 01:54:17 +00:00
|
|
|
else
|
|
|
|
yes | sudo ./dojo.sh upgrade &
|
2020-09-26 01:28:16 +00:00
|
|
|
INSTALL_PID=$!
|
2020-05-13 01:54:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#Check for install/upgrade to finish to initialize Dojo mysql db
|
2021-01-25 04:46:22 +00:00
|
|
|
sudo /usr/bin/mynode_post_dojo.sh
|
2020-05-13 01:54:17 +00:00
|
|
|
|
2020-09-26 01:28:16 +00:00
|
|
|
# Wait for install script to finish
|
2021-01-25 04:46:22 +00:00
|
|
|
wait $INSTALL_PID || MARK_DOJO_COMPLETE=0
|
|
|
|
|
2020-09-26 01:28:16 +00:00
|
|
|
|
|
|
|
# Try and start dojo (if upgraded and already enabled)
|
2021-02-05 01:40:05 +00:00
|
|
|
systemctl enable dojo &
|
2021-01-25 04:46:22 +00:00
|
|
|
systemctl restart dojo &
|
2020-09-26 01:28:16 +00:00
|
|
|
|
2021-01-25 04:46:22 +00:00
|
|
|
# Mark dojo install complete
|
|
|
|
if [ $MARK_DOJO_COMPLETE = 1 ]; then
|
|
|
|
echo $DOJO_UPGRADE_URL > $DOJO_UPGRADE_URL_FILE
|
|
|
|
fi
|
2020-03-01 18:40:59 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-02-23 21:55:37 +00:00
|
|
|
rm -f /tmp/installing_docker_images
|
2021-02-23 02:39:14 +00:00
|
|
|
touch /tmp/installing_docker_images_completed_once
|
2020-02-23 21:55:37 +00:00
|
|
|
|
|
|
|
# Wait a day
|
|
|
|
sleep 1d
|
|
|
|
done
|
|
|
|
|
|
|
|
# We should not exit
|
|
|
|
exit 1
|