Browse Source

Merge pull request #123 from Samourai-Wallet/enh_mydojo_install

add controls and confirmations before reinstalls and uninstalls
feat_mydojo_bitcoin_0_19_1
kenshin samourai 5 years ago
committed by GitHub
parent
commit
eecd985ac3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      docker/my-dojo/conf/docker-mysql.conf.tpl
  2. 56
      docker/my-dojo/dojo.sh
  3. 12
      docker/my-dojo/install/install-scripts.sh
  4. 15
      docker/my-dojo/install/uninstall-scripts.sh

3
docker/my-dojo/conf/docker-mysql.conf.tpl

@ -3,13 +3,16 @@
#########################################
# Password of MySql root account
# Warning: This option must not be modified after the first installation
# Type: alphanumeric
MYSQL_ROOT_PASSWORD=rootpassword
# User account used for db access
# Warning: This option must not be modified after the first installation
# Type: alphanumeric
MYSQL_USER=samourai
# Password of of user account
# Warning: This option must not be modified after the first installation
# Type: alphanumeric
MYSQL_PASSWORD=password

56
docker/my-dojo/dojo.sh

@ -152,6 +152,30 @@ install() {
launchInstall=$?
fi
# Detection of past install
if [ $launchInstall -eq 0 ]; then
pastInstallsfound=$(docker image ls | grep samouraiwallet/dojo-db | wc -l)
if [ $pastInstallsfound -ne 0 ]; then
# Past installation found. Ask confirmation forreinstall
echo -e "\nWarning: Found traces of a previous installation of Dojo on this machine."
echo "A new installation requires to remove these elements first."
get_confirmation_reinstall
launchReinstall=$?
if [ $launchReinstall -eq 0 ]; then
# Uninstall
echo ""
uninstall
launchReinstall=$?
fi
if [ $launchReinstall -eq 1 ]; then
launchInstall=1
echo -e "\nInstallation was cancelled."
fi
fi
fi
# Installation
if [ $launchInstall -eq 0 ]; then
# Initialize the config files
@ -167,20 +191,30 @@ install() {
# Delete everything
uninstall() {
docker-compose rm
source "$DIR/install/uninstall-scripts.sh"
yamlFiles=$(select_yaml_files)
eval "docker-compose $yamlFiles down"
get_confirmation
launchUninstall=$?
docker image rm samouraiwallet/dojo-db:"$DOJO_DB_VERSION_TAG"
docker image rm samouraiwallet/dojo-bitcoind:"$DOJO_BITCOIND_VERSION_TAG"
docker image rm samouraiwallet/dojo-explorer:"$DOJO_EXPLORER_VERSION_TAG"
docker image rm samouraiwallet/dojo-nodejs:"$DOJO_NODEJS_VERSION_TAG"
docker image rm samouraiwallet/dojo-nginx:"$DOJO_NGINX_VERSION_TAG"
docker image rm samouraiwallet/dojo-tor:"$DOJO_TOR_VERSION_TAG"
docker image rm samouraiwallet/dojo-indexer:"$DOJO_INDEXER_VERSION_TAG"
if [ $launchUninstall -eq 0 ]; then
docker-compose rm
docker volume prune
yamlFiles=$(select_yaml_files)
eval "docker-compose $yamlFiles down"
docker image rm samouraiwallet/dojo-db:"$DOJO_DB_VERSION_TAG"
docker image rm samouraiwallet/dojo-bitcoind:"$DOJO_BITCOIND_VERSION_TAG"
docker image rm samouraiwallet/dojo-explorer:"$DOJO_EXPLORER_VERSION_TAG"
docker image rm samouraiwallet/dojo-nodejs:"$DOJO_NODEJS_VERSION_TAG"
docker image rm samouraiwallet/dojo-nginx:"$DOJO_NGINX_VERSION_TAG"
docker image rm samouraiwallet/dojo-tor:"$DOJO_TOR_VERSION_TAG"
docker image rm samouraiwallet/dojo-indexer:"$DOJO_INDEXER_VERSION_TAG"
docker volume prune
return 0
else
return 1
fi
}
# Clean-up (remove old docker images)

12
docker/my-dojo/install/install-scripts.sh

@ -31,6 +31,18 @@ get_confirmation() {
done
}
# Confirm reinstallation
get_confirmation_reinstall() {
while true; do
read -p "Do you really wish to reinstall Dojo on your computer? [y/n]" yn
case $yn in
[Yy]* ) return 0;;
[Nn]* ) echo "Reinstallation was cancelled."; return 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
# Initialize configuration files from templates
init_config_files() {
# Initialize db scripts

15
docker/my-dojo/install/uninstall-scripts.sh

@ -0,0 +1,15 @@
#!/bin/bash
# Confirm uninstallation
get_confirmation() {
while true; do
echo "This operation is going to uninstall Dojo from your computer."
echo "Warning: This will delete from disk all the data stored by your Dojo (blockchain data, Dojo db, etc)."
read -p "Do you wish to continue? [y/n]" yn
case $yn in
[Yy]* ) return 0;;
[Nn]* ) echo "Uninstallation was cancelled."; return 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
Loading…
Cancel
Save