Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean-up #11

Merged
merged 2 commits into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/DOCKER_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion docker/my-dojo/dojo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -255,6 +277,9 @@ case "$subcommand" in
help )
help
;;
clean )
clean
;;
install )
install $1
;;
Expand Down
4 changes: 3 additions & 1 deletion docker/my-dojo/install/upgrade-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}