10 echo "Wait until $max_attempts seconds for MySQL mano Server ${db_host}:${db_port} "
11 while ! mysqladmin
ping -h"$db_host" -P"$db_port" --silent; do
13 if [ $attempt -ge $max_attempts ]; then
15 echo "Can not connect to database ${db_host}:${db_port} during $max_attempts sec"
25 function is_db_created
() {
32 if mysqlshow
-h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" |
grep -v Wildcard |
grep -q $db_name; then
33 echo "DB $db_name exists"
36 echo "DB $db_name does not exist"
41 if [[ $OSMUI_SQL_DATABASE_URI == *'mysql'* ]]; then
42 DB_HOST
=$
(echo $OSMUI_SQL_DATABASE_URI |
sed -r 's|^.+://.+:.+@(.+):.*$|\1|')
43 DB_PORT
=$
(echo $OSMUI_SQL_DATABASE_URI |
sed -r 's|^.+://.*:([0-9]+).*$|\1|')
44 DB_USER
=$
(echo $OSMUI_SQL_DATABASE_URI |
sed -r 's|^.+://(.+):.+@.+$|\1|')
45 DB_PASSWORD
=$
(echo $OSMUI_SQL_DATABASE_URI |
sed -r 's|^.+://.+:(.+)@.*$|\1|')
46 DB_NAME
=$
(echo $OSMUI_SQL_DATABASE_URI |
sed -r 's|^.+://.+:.+@.+:.*/(\w+)(\?.*)?$|\1|')
48 wait_db
"$DB_HOST" "$DB_PORT" ||
exit 1
50 is_db_created
"$DB_HOST" "$DB_PORT" "$DB_USER" "$DB_PASSWORD" "$DB_NAME" && DB_EXISTS
="Y"
52 if [ -z $DB_EXISTS ]; then
53 mysql
-h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" --default_character_set utf8
-e "CREATE DATABASE $DB_NAME"
57 python manage.py makemigrations authosm
58 python manage.py migrate