3 # Copyright (c) 2019 AT&T Intellectual Property. All other rights reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Use this script if the persistent storage does not exist
19 DOCKER_VOLUME_NAME="akraino-validation-mariadb"
21 CONTAINER_NAME="akraino-validation-mariadb"
22 # Container input variables
23 MARIADB_ROOT_PASSWORD=""
24 MARIADB_AKRAINO_PASSWORD=""
26 UI_AKRAINO_PASSWORD=""
32 MARIADB_HOST_PORT=3307
36 KEY=$(echo $ARGUMENT | cut -f1 -d=)
37 VALUE=$(echo $ARGUMENT | cut -f2 -d=)
39 REGISTRY) REGISTRY=${VALUE} ;;
40 NAME) NAME=${VALUE} ;;
41 TAG_VER) TAG_VER=${VALUE} ;;
42 TAG_PRE) TAG_PRE=${VALUE} ;;
43 MARIADB_ROOT_PASSWORD) MARIADB_ROOT_PASSWORD=${VALUE} ;;
44 MARIADB_AKRAINO_PASSWORD) MARIADB_AKRAINO_PASSWORD=${VALUE} ;;
45 CONTAINER_NAME) CONTAINER_NAME=${VALUE} ;;
46 MARIADB_HOST_PORT) MARIADB_HOST_PORT=${VALUE} ;;
47 UI_ADMIN_PASSWORD) UI_ADMIN_PASSWORD=${VALUE} ;;
48 UI_AKRAINO_PASSWORD) UI_AKRAINO_PASSWORD=${VALUE} ;;
53 if [ -z "$MARIADB_ROOT_PASSWORD" ]
55 echo "ERROR: You must specify the mariadb database root password"
59 if [ -z "$MARIADB_AKRAINO_PASSWORD" ]
61 echo "ERROR: You must specify the mariadb database akraino user password"
65 if [ -z "$UI_ADMIN_PASSWORD" ]
67 echo "ERROR: You must specify the password of the UI admin user"
71 if [ -z "$UI_AKRAINO_PASSWORD" ]
73 echo "ERROR: You must specify the password for the UI akraino user"
77 IMAGE="$REGISTRY"/"$NAME":"$TAG_PRE"-"$TAG_VER"
78 chmod 0444 "/$(pwd)/mariadb.conf"
79 docker run --detach --name $CONTAINER_NAME --publish $MARIADB_HOST_PORT:3306 -v $DOCKER_VOLUME_NAME:/var/lib/mysql -v "/$(pwd)/mariadb.conf:/etc/mysql/conf.d/my.cnf" -e MYSQL_ROOT_PASSWORD="$MARIADB_ROOT_PASSWORD" -e MYSQL_DATABASE="akraino" -e MYSQL_USER="akraino" -e MYSQL_PASSWORD="$MARIADB_AKRAINO_PASSWORD" -e UI_ADMIN_PASSWORD="$UI_ADMIN_PASSWORD" -e UI_AKRAINO_PASSWORD="$UI_AKRAINO_PASSWORD" $IMAGE
80 docker exec $CONTAINER_NAME /bin/bash -c 'sed -i 's/admin_password/'"$UI_ADMIN_PASSWORD"'/g' /docker-entrypoint-initdb.d/EcompSdkDMLMySql_2_4_OS.sql ; sed -i 's/akraino_password/'"$UI_AKRAINO_PASSWORD"'/g' /docker-entrypoint-initdb.d/EcompSdkDMLMySql_2_4_OS.sql; continue=`ps aux | grep mysql` ; while [ -z "$continue" ]; do continue=`ps aux | grep mysql`; sleep 5; done ; sleep 10 ;'