From b2819af937c3e0e8ab2b72378992af5b7dd0c13a Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Sun, 16 Jun 2019 14:34:42 +0200 Subject: [PATCH 1/2] fix - check that bitcoin.conf file exists before deletion --- docker/my-dojo/install/upgrade-scripts.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/my-dojo/install/upgrade-scripts.sh b/docker/my-dojo/install/upgrade-scripts.sh index 0ac4071..757bd6e 100755 --- a/docker/my-dojo/install/upgrade-scripts.sh +++ b/docker/my-dojo/install/upgrade-scripts.sh @@ -61,5 +61,7 @@ cleanup() { ################# # Remove deprecated bitcoin.conf file - rm ./bitcoin/bitcoin.conf + if [ -f ./bitcoin/bitcoin.conf ]; then + rm ./bitcoin/bitcoin.conf + fi } From f8df0e37bb7fac649c1778d162f4bb80db97521b Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Sun, 16 Jun 2019 14:35:36 +0200 Subject: [PATCH 2/2] add new clean command to dojo.sh --- doc/DOCKER_setup.md | 2 ++ docker/my-dojo/dojo.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/DOCKER_setup.md b/doc/DOCKER_setup.md index 0351dda..bec2a8b 100644 --- a/doc/DOCKER_setup.md +++ b/doc/DOCKER_setup.md @@ -163,6 +163,8 @@ Available commands: bitcoin-cli Launch a bitcoin-cli console for interacting with bitcoind RPC API. + clean Free disk space by deleting docker dangling images and images of previous versions. + install Install your Dojo. logs [module] [options] Display the logs of your Dojo. Use CTRL+C to stop the logs. diff --git a/docker/my-dojo/dojo.sh b/docker/my-dojo/dojo.sh index 7b954a8..7c1175e 100755 --- a/docker/my-dojo/dojo.sh +++ b/docker/my-dojo/dojo.sh @@ -12,7 +12,7 @@ source_file() { source_file "$DIR/conf/docker-bitcoind.conf" source_file "$DIR/.env" - + # Docker up docker_up() { source_file "$DIR/conf/docker-bitcoind.conf" @@ -97,6 +97,26 @@ uninstall() { docker volume prune } +# Clean-up (remove old docker images) +del_images_for() { + # $1: image name + # $2: most recent version of the image (do not delete this one) + docker image ls | grep "$1" | sed "s/ \+/,/g" | cut -d"," -f2 | while read -r version ; do + if [ "$2" != "$version" ]; then + docker image rm "$1:$version" + fi + done +} + +clean() { + docker image prune + del_images_for samouraiwallet/dojo-db "$DOJO_DB_VERSION_TAG" + del_images_for samouraiwallet/dojo-bitcoind "$DOJO_BITCOIND_VERSION_TAG" + del_images_for samouraiwallet/dojo-nodejs "$DOJO_NODEJS_VERSION_TAG" + del_images_for samouraiwallet/dojo-nginx "$DOJO_NGINX_VERSION_TAG" + del_images_for samouraiwallet/dojo-tor "$DOJO_TOR_VERSION_TAG" +} + # Upgrade upgrade() { source "$DIR/install/upgrade-scripts.sh" @@ -183,6 +203,8 @@ help() { echo " " echo " bitcoin-cli Launch a bitcoin-cli console allowing to interact with your full node through its RPC API." echo " " + echo " clean Free disk space by deleting docker dangling images and images of previous versions." + echo " " echo " install Install your dojo." echo " " echo " logs [module] [options] Display the logs of your dojo. Use CTRL+C to stop the logs." @@ -255,6 +277,9 @@ case "$subcommand" in help ) help ;; + clean ) + clean + ;; install ) install $1 ;;