From 708ebda5487943461212d63e4376daaeeb8aceb5 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Sun, 1 Mar 2020 14:53:50 -0600 Subject: [PATCH] Dojo waits for docker image installation; Dojo reinstall resets config --- rootfs/standard/etc/systemd/system/dojo.service | 4 +++- .../etc/systemd/system/mempoolspace.service | 1 + rootfs/standard/usr/bin/mynode_docker_images.sh | 1 + rootfs/standard/usr/bin/mynode_post_dojo.sh | 2 +- rootfs/standard/usr/bin/mynode_reinstall_app.sh | 2 ++ .../usr/bin/wait_on_docker_image_install.sh | 14 ++++++++++++++ rootfs/standard/usr/bin/wait_on_electrs.sh | 2 +- 7 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 rootfs/standard/usr/bin/wait_on_docker_image_install.sh diff --git a/rootfs/standard/etc/systemd/system/dojo.service b/rootfs/standard/etc/systemd/system/dojo.service index 2de93972..4755ea8c 100644 --- a/rootfs/standard/etc/systemd/system/dojo.service +++ b/rootfs/standard/etc/systemd/system/dojo.service @@ -3,11 +3,13 @@ [Unit] Description=Dojo -After=network.target mynode.service +After=network.target mynode.service docker_images.service [Service] Type=forking RemainAfterExit=yes +ExecStartPre=/usr/bin/wait_on_bitcoin.sh +ExecStartPre=/usr/bin/wait_on_docker_image_install.sh WorkingDirectory=/opt/mynode/dojo/docker/my-dojo ExecStart=/opt/mynode/dojo/docker/my-dojo/dojo.sh start ExecStop=/opt/mynode/dojo/docker/my-dojo/dojo.sh stop diff --git a/rootfs/standard/etc/systemd/system/mempoolspace.service b/rootfs/standard/etc/systemd/system/mempoolspace.service index 6a2a9e48..18069d2b 100644 --- a/rootfs/standard/etc/systemd/system/mempoolspace.service +++ b/rootfs/standard/etc/systemd/system/mempoolspace.service @@ -9,6 +9,7 @@ After=www.service docker_images.service [Service] EnvironmentFile=/mnt/hdd/mynode/settings/.btcrpc_environment ExecStartPre=/usr/bin/wait_on_bitcoin.sh +ExecStartPre=/usr/bin/wait_on_docker_image_install.sh ExecStart=/usr/bin/docker run --rm --name mempoolspace -p 4080:80 -e BITCOIN_NODE_HOST=172.17.0.1 -e BITCOIN_NODE_USER=mynode -e BITCOIN_NODE_PASS=${BTC_RPC_PASSWORD} -e MEMPOOL_REFRESH_RATE_MS=5000 mempoolspace ExecStop=/usr/bin/docker stop -t 2 mempoolspace diff --git a/rootfs/standard/usr/bin/mynode_docker_images.sh b/rootfs/standard/usr/bin/mynode_docker_images.sh index bc892325..4909eda3 100755 --- a/rootfs/standard/usr/bin/mynode_docker_images.sh +++ b/rootfs/standard/usr/bin/mynode_docker_images.sh @@ -6,6 +6,7 @@ set -x source /usr/share/mynode/mynode_config.sh echo "Starting mynode_docker_images.sh ..." +touch /tmp/installing_docker_images # Drive should be mounted, let's still wait a bit sleep 10s diff --git a/rootfs/standard/usr/bin/mynode_post_dojo.sh b/rootfs/standard/usr/bin/mynode_post_dojo.sh index aa5e7b16..9db08e4b 100755 --- a/rootfs/standard/usr/bin/mynode_post_dojo.sh +++ b/rootfs/standard/usr/bin/mynode_post_dojo.sh @@ -6,7 +6,7 @@ sleep 10s #dojo needs time to start before passing next line # initalize mysql db (REQUIRED TO START MYSQL) counter=0 -target=50 +target=100 isRunning="" MYSQL_DATABASE=samourai-main diff --git a/rootfs/standard/usr/bin/mynode_reinstall_app.sh b/rootfs/standard/usr/bin/mynode_reinstall_app.sh index 4ed8475e..2221292e 100755 --- a/rootfs/standard/usr/bin/mynode_reinstall_app.sh +++ b/rootfs/standard/usr/bin/mynode_reinstall_app.sh @@ -45,6 +45,8 @@ elif [ "$APP" = "whirlpool" ]; then elif [ "$APP" = "dojo" ]; then rm -f /mnt/hdd/mynode/settings/dojo_url cd /opt/mynode/dojo/docker/my-dojo/ + rm -f ./conf/docker-node.conf + rm -f ./conf/docker-mysql.conf echo "y" | ./dojo.sh uninstall else echo "UNKNOWN APP: $APP" diff --git a/rootfs/standard/usr/bin/wait_on_docker_image_install.sh b/rootfs/standard/usr/bin/wait_on_docker_image_install.sh new file mode 100755 index 00000000..ec430799 --- /dev/null +++ b/rootfs/standard/usr/bin/wait_on_docker_image_install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -x + +# Wait a few second to give marker file a change to get created +sleep 10s + +# Check if +echo "Checking if docker images have been installed..." +while [ -f /tmp/installing_docker_images ]; do + sleep 10s +done + +exit 0 \ No newline at end of file diff --git a/rootfs/standard/usr/bin/wait_on_electrs.sh b/rootfs/standard/usr/bin/wait_on_electrs.sh index 3e8f1097..e89e41d6 100755 --- a/rootfs/standard/usr/bin/wait_on_electrs.sh +++ b/rootfs/standard/usr/bin/wait_on_electrs.sh @@ -3,7 +3,7 @@ set -x set -e -# Wait to see if bitcoind is synced +# Wait to see if electrs is synced echo "Checking if electrum server is ready is synced..." while [ ! -f "/tmp/electrs_up_to_date" ]; do echo "electrs not synced, sleeping 1m"