kenshin-samourai
6 years ago
13 changed files with 236 additions and 36 deletions
@ -0,0 +1,7 @@ |
|||||
|
# SQL scripts for incremental updates |
||||
|
|
||||
|
# Copyright © 2019 – Katana Cryptographic Ltd. All Rights Reserved. |
||||
|
|
||||
|
-- |
||||
|
-- UPDATES vX.Y.Z |
||||
|
-- |
@ -0,0 +1,34 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Confirm installation |
||||
|
get_confirmation() { |
||||
|
while true; do |
||||
|
echo "This operation is going to install Dojo v$DOJO_VERSION_TAG on your computer." |
||||
|
read -p "Do you wish to continue? [y/n]" yn |
||||
|
case $yn in |
||||
|
[Yy]* ) return 0;; |
||||
|
[Nn]* ) echo "Installation was cancelled."; return 1;; |
||||
|
* ) echo "Please answer yes or no.";; |
||||
|
esac |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
# Initialize configuration files from templates |
||||
|
init_config_files() { |
||||
|
cp ../../db-scripts/1_db.sql.tpl ../../db-scripts/1_db.sql |
||||
|
echo "Initialized 1_db.sql" |
||||
|
|
||||
|
if [ -f ../../db-scripts/2_update.sql ]; then |
||||
|
rm ../../db-scripts/2_update.sql |
||||
|
echo "Deleted 2_update.sql" |
||||
|
fi |
||||
|
|
||||
|
cp ./conf/docker-bitcoind.conf.tpl ./conf/docker-bitcoind.conf |
||||
|
echo "Initialized docker-bitcoind.conf" |
||||
|
|
||||
|
cp ./conf/docker-mysql.conf.tpl ./conf/docker-mysql.conf |
||||
|
echo "Initialized docker-mysql.conf" |
||||
|
|
||||
|
cp ./conf/docker-node.conf.tpl ./conf/docker-node.conf |
||||
|
echo "Initialized docker-node.conf" |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Confirm upgrade operation |
||||
|
get_confirmation() { |
||||
|
while true; do |
||||
|
echo "This operation is going to upgrade your Dojo to v$DOJO_VERSION_TAG." |
||||
|
read -p "Do you wish to continue? [y/n]" yn |
||||
|
case $yn in |
||||
|
[Yy]* ) return 0;; |
||||
|
[Nn]* ) echo "Upgrade was cancelled."; return 1;; |
||||
|
* ) echo "Please answer yes or no.";; |
||||
|
esac |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
# Update configuration files from templates |
||||
|
update_config_files() { |
||||
|
if [ -f ../../db-scripts/1_db.sql ]; then |
||||
|
rm ../../db-scripts/1_db.sql |
||||
|
echo "Deleted 1_db.sql" |
||||
|
fi |
||||
|
|
||||
|
cp ../../db-scripts/2_update.sql.tpl ../../db-scripts/2_update.sql |
||||
|
echo "Initialized 2_update.sql" |
||||
|
|
||||
|
update_config_file ./conf/docker-bitcoind.conf ./conf/docker-bitcoind.conf.tpl |
||||
|
echo "Initialized docker-bitcoind.conf" |
||||
|
|
||||
|
update_config_file ./conf/docker-mysql.conf ./conf/docker-mysql.conf.tpl |
||||
|
echo "Initialized docker-mysql.conf" |
||||
|
|
||||
|
update_config_file ./conf/docker-node.conf ./conf/docker-node.conf.tpl |
||||
|
echo "Initialized docker-node.conf" |
||||
|
} |
||||
|
|
||||
|
# Update a configuration file from template |
||||
|
update_config_file() { |
||||
|
sed "/^#.*/P;s/=.*//g;/^$/d" $1 > ./original.raw |
||||
|
sed "/^#.*/P;s/=.*//g;/^$/d" $2 > ./tpl.raw |
||||
|
grep -vf ./original.raw ./tpl.raw > ./newvals.dat |
||||
|
|
||||
|
cp -p $1 "$1.save" |
||||
|
|
||||
|
echo " |
||||
|
" >> $1 |
||||
|
|
||||
|
grep -f ./newvals.dat $2 >> $1 |
||||
|
|
||||
|
rm ./original.raw |
||||
|
rm ./tpl.raw |
||||
|
rm ./newvals.dat |
||||
|
} |
||||
|
|
||||
|
# Update dojo database |
||||
|
update_dojo_db() { |
||||
|
docker exec -d db /update-db.sh |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
for i in {30..0}; do |
||||
|
if echo "SELECT 1" | mysql -h"db" -u"root" -p"$MYSQL_ROOT_PASSWORD" &> /dev/null; then |
||||
|
break |
||||
|
fi |
||||
|
echo "MySQL init process in progress..." |
||||
|
sleep 1 |
||||
|
done |
||||
|
|
||||
|
if [ -f /docker-entrypoint-initdb.d/2_update.sql ]; then |
||||
|
mysql -h"db" -u"root" -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" < /docker-entrypoint-initdb.d/2_update.sql |
||||
|
echo "Updated database with 2_update.sql" |
||||
|
fi |
Loading…
Reference in new issue