Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / policy / resources / config / db-pg.sh
1 #!/bin/sh
2 #
3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2021-2022 Nordix Foundation.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # SPDX-License-Identifier: Apache-2.0
16 # ============LICENSE_END=========================================================
17 #
18
19 #psql() { /usr/bin/psql  -h ${PG_HOST} -p ${PG_PORT} "$@"; };
20
21 export PGPASSWORD=${PG_ADMIN_PASSWORD};
22
23 psql -h ${PG_HOST} -p ${PG_PORT} -U postgres --command "CREATE USER ${PG_USER} WITH PASSWORD '${PG_USER_PASSWORD}'"
24
25 for db in migration pooling policyadmin policyclamp operationshistory clampacm
26 do
27     psql -h ${PG_HOST} -p ${PG_PORT} -U postgres --command "CREATE DATABASE ${db};"
28     psql -h ${PG_HOST} -p ${PG_PORT} -U postgres --command "GRANT ALL PRIVILEGES ON DATABASE ${db} TO ${PG_USER};"
29 done