2020-02-28 01:25:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-04-11 19:43:23 +00:00
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2020-04-05 23:27:21 +00:00
|
|
|
sleep 30s #dojo needs time to start before passing next line
|
2020-02-28 01:25:33 +00:00
|
|
|
|
|
|
|
# initalize mysql db (REQUIRED TO START MYSQL)
|
|
|
|
counter=0
|
2020-04-05 23:27:21 +00:00
|
|
|
target=200
|
2020-02-28 01:25:33 +00:00
|
|
|
isRunning=""
|
|
|
|
MYSQL_DATABASE=samourai-main
|
|
|
|
|
|
|
|
# check on loop if mysql db is running. when running initialize
|
|
|
|
while [ $counter != $target ]
|
|
|
|
do
|
|
|
|
|
2021-01-23 04:55:44 +00:00
|
|
|
source /mnt/hdd/mynode/dojo/docker/my-dojo/conf/docker-mysql.conf || exit 0
|
2020-02-28 01:25:33 +00:00
|
|
|
|
|
|
|
# Check if dojo mysql db is running (check the db container)
|
|
|
|
isRunning=$(docker inspect --format="{{.State.Running}}" db)
|
2020-03-01 18:40:59 +00:00
|
|
|
if [ "$isRunning" == "true" ]; then
|
2020-04-05 23:27:21 +00:00
|
|
|
sleep 60s
|
2020-04-11 19:56:25 +00:00
|
|
|
if [ $IS_RASPI == 1 ]; then
|
2021-01-23 04:55:44 +00:00
|
|
|
docker exec -i db bash -c "mysql -h db -u root -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE" </mnt/hdd/mynode/dojo/db-scripts/1_db.sql
|
2020-04-11 19:43:23 +00:00
|
|
|
fi
|
2020-02-28 01:25:33 +00:00
|
|
|
echo "dojo mysql db initalized"
|
|
|
|
sleep 5s
|
2020-04-05 23:27:21 +00:00
|
|
|
# Stop dojo after install/update and initalization is complete
|
2021-01-23 04:55:44 +00:00
|
|
|
cd /mnt/hdd/mynode/dojo/docker/my-dojo
|
2020-02-28 01:25:33 +00:00
|
|
|
sudo ./dojo.sh stop
|
|
|
|
counter=$target
|
|
|
|
else
|
|
|
|
echo "waiting to initalize dojo mysql db - retrying $[ $target-$counter ] more times"
|
|
|
|
counter=$(( $counter + 1 ))
|
|
|
|
sleep 30s
|
|
|
|
fi
|
|
|
|
done || exit 0
|