blob: f26a80fad75d36e9c3c27e7b4bb2436d0946108c [file] [log] [blame]
waynedunican368aced2022-02-15 08:27:57 +00001#!/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
21export PGPASSWORD=${PG_ADMIN_PASSWORD};
22
23psql -h ${PG_HOST} -p ${PG_PORT} -U postgres --command "CREATE USER ${PG_USER} WITH PASSWORD '${PG_USER_PASSWORD}'"
24
25for db in migration pooling policyadmin policyclamp operationshistory clampacm
26do
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};"
29done