Merge "[CONSUL] Add limits to consul chart."
[oom.git] / kubernetes / common / mariadb-init / resources / config / db_init.sh
index b2fdb14..fa4b007 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+{{/*
 # Copyright © 2019 Orange
 # Copyright © 2020 Samsung Electronics
 #
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+*/}}
+
+# make sure the script fails if any of commands failed
+set -e
 
 while read DB ; do
     USER_VAR="MYSQL_USER_${DB^^}"
     PASS_VAR="MYSQL_PASSWORD_${DB^^}"
     USER=${!USER_VAR}
-    PASS=${!PASS_VAR}
+    PASS=`echo -n ${!PASS_VAR} | sed -e "s/'/''/g"`
     MYSQL_OPTS=( -h ${DB_HOST} -P ${DB_PORT} -uroot -p${MYSQL_ROOT_PASSWORD} )
 
     echo "Creating database ${DB} and user ${USER}..."