kenshin samourai
6 years ago
committed by
GitHub
13 changed files with 246 additions and 45 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,55 @@ |
|||
#!/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 "s/^#.*//g;s/=.*//g;/^$/d" $1 > ./original.keys.raw |
|||
grep -f ./original.keys.raw $1 > ./original.lines.raw |
|||
|
|||
cp -p $1 "$1.save" |
|||
cp -p $2 $1 |
|||
|
|||
while IFS='=' read -r key val ; do |
|||
sed -i "s/$key=.*/$key=$val/g" "$1" |
|||
done < ./original.lines.raw |
|||
|
|||
rm ./original.keys.raw |
|||
rm ./original.lines.raw |
|||
} |
|||
|
|||
# Update dojo database |
|||
update_dojo_db() { |
|||
docker exec -d db /update-db.sh |
|||
} |
@ -1,7 +1,13 @@ |
|||
FROM mysql:5.7.25 |
|||
FROM mysql:5.7.25 |
|||
|
|||
# Copy mysql config |
|||
COPY ./docker/my-dojo/mysql/mysql-dojo.cnf /etc/mysql/conf.d/mysql-dojo.cnf |
|||
COPY ./docker/my-dojo/mysql/mysql-dojo.cnf /etc/mysql/conf.d/mysql-dojo.cnf |
|||
|
|||
# Copy update-db script |
|||
COPY ./docker/my-dojo/mysql/update-db.sh /update-db.sh |
|||
|
|||
RUN chmod u+x /update-db.sh && \ |
|||
chmod g+x /update-db.sh |
|||
|
|||
# Copy content of mysql scripts into /docker-entrypoint-initdb.d |
|||
COPY ./db-scripts/ /docker-entrypoint-initdb.d |
|||
COPY ./db-scripts/ /docker-entrypoint-initdb.d |
@ -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