Improve docker image install/launch consistency

This commit is contained in:
Taylor Helsper 2020-02-22 22:20:31 -06:00
parent e1f2c86bd6
commit 139a1705dd
3 changed files with 54 additions and 56 deletions

View File

@ -9,7 +9,6 @@ Requires=docker.service network-online.target bitcoind.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStart=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_up' ExecStart=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_up'
ExecStop=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_down' ExecStop=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_down'
ExecReload=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_restart' ExecReload=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_restart'

View File

@ -7,17 +7,16 @@ Wants=mynode.service
After=mynode.service After=mynode.service
[Service] [Service]
Type=simple Type=oneshot
KillMode=control-group
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStart=/usr/bin/mynode_docker_images.sh ExecStart=/usr/bin/mynode_docker_images.sh
User=root User=root
Group=root Group=root
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog
SyslogIdentifier=mynode_docker_images SyslogIdentifier=mynode_docker_images
Restart=always
RestartSec=300 RestartSec=30
RemainAfterExit=yes
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -13,45 +13,45 @@ sleep 60s
echo "Waiting on bitcoin to sync so drive usage is lower..." echo "Waiting on bitcoin to sync so drive usage is lower..."
/usr/bin/wait_on_bitcoin.sh /usr/bin/wait_on_bitcoin.sh
# Loop and check every 1 day
while [ 1 ]; do
echo "Checking for building new docker images..." echo "Checking for building new docker images..."
touch /tmp/installing_docker_images touch /tmp/installing_docker_images
# Upgrade WebSSH2 # Pull images that don't need to be built
echo "Checking for new webssh2..." docker pull netdata/netdata
WEBSSH2_UPGRADE_URL=https://github.com/billchurch/webssh2/archive/v0.2.10-0.tar.gz
WEBSSH2_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/webssh2_url # Upgrade WebSSH2
CURRENT="" echo "Checking for new webssh2..."
if [ -f $WEBSSH2_UPGRADE_URL_FILE ]; then WEBSSH2_UPGRADE_URL=https://github.com/billchurch/webssh2/archive/v0.2.10-0.tar.gz
WEBSSH2_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/webssh2_url
CURRENT=""
if [ -f $WEBSSH2_UPGRADE_URL_FILE ]; then
CURRENT=$(cat $WEBSSH2_UPGRADE_URL_FILE) CURRENT=$(cat $WEBSSH2_UPGRADE_URL_FILE)
fi fi
if [ "$CURRENT" != "$WEBSSH2_UPGRADE_URL" ]; then if [ "$CURRENT" != "$WEBSSH2_UPGRADE_URL" ]; then
docker rmi webssh2 || true docker rmi webssh2 || true
cd /opt/mynode cd /tmp/
rm -rf webssh2 rm -rf webssh2
wget $WEBSSH2_UPGRADE_URL -O webssh2.tar.gz wget $WEBSSH2_UPGRADE_URL -O webssh2.tar.gz
tar -xvf webssh2.tar.gz tar -xvf webssh2.tar.gz
rm webssh2.tar.gz rm webssh2.tar.gz
mv webssh2-* webssh2 mv webssh2-* webssh2
cd webssh2 cd webssh2
mv app/config.json.sample app/config.json
docker build -t webssh2 . docker build -t webssh2 .
echo $WEBSSH2_UPGRADE_URL > $WEBSSH2_UPGRADE_URL_FILE echo $WEBSSH2_UPGRADE_URL > $WEBSSH2_UPGRADE_URL_FILE
fi fi
# Upgrade mempool.space # Upgrade mempool.space
echo "Checking for new mempool.space..." echo "Checking for new mempool.space..."
MEMPOOLSPACE_UPGRADE_URL=https://github.com/mempool-space/mempool.space/archive/master.zip MEMPOOLSPACE_UPGRADE_URL=https://github.com/mempool-space/mempool.space/archive/8835c399e9b00c2579ed0bbd72f8cca4c5823dad.zip
MEMPOOLSPACE_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/mempoolspace_url MEMPOOLSPACE_UPGRADE_URL_FILE=/mnt/hdd/mynode/settings/mempoolspace_url
CURRENT="" CURRENT=""
if [ -f $MEMPOOLSPACE_UPGRADE_URL_FILE ]; then if [ -f $MEMPOOLSPACE_UPGRADE_URL_FILE ]; then
CURRENT=$(cat $MEMPOOLSPACE_UPGRADE_URL_FILE) CURRENT=$(cat $MEMPOOLSPACE_UPGRADE_URL_FILE)
fi fi
if [ "$CURRENT" != "$MEMPOOLSPACE_UPGRADE_URL" ]; then if [ "$CURRENT" != "$MEMPOOLSPACE_UPGRADE_URL" ]; then
docker rmi mempoolspace || true docker rmi mempoolspace || true
cd /opt/mynode cd /opt/mynode
@ -61,14 +61,14 @@ while [ 1 ]; do
rm mempool.zip rm mempool.zip
mv mempool* mempoolspace mv mempool* mempoolspace
cd mempoolspace cd mempoolspace
sync
sleep 3s
docker build -t mempoolspace . docker build -t mempoolspace .
echo $MEMPOOLSPACE_UPGRADE_URL > $MEMPOOLSPACE_UPGRADE_URL_FILE echo $MEMPOOLSPACE_UPGRADE_URL > $MEMPOOLSPACE_UPGRADE_URL_FILE
fi fi
rm -f /tmp/installing_docker_images rm -f /tmp/installing_docker_images
# Check again in a day
echo "Waiting a day..." exit 0
sleep 24h
done