Files
openlan-cgw/utils/docker/postgresql/init-db.sh
Oleksandr Mazur abb99f544c Add proper all-in-one make job
This change makes it possibly to fire make all / make run
without any additional prerequisites required.
It instructs Makefile to launch docker compose for thirdparty
services, as well as instructs CGW container to communicate
with newly created containers.
Also generates self-signed certs, in case if these are missing.

- Tweak docker-compose files for thirdparty services to resign
  in a cgw-dedicated network, and use hostnames where needed;
- Change CGW app default network to cgw-dedicated network;
- Tweak PGSQL scripts to create tables in CGW DB, as well
  as change ownership to them.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
2024-10-02 14:37:13 +03:00

14 lines
635 B
Bash
Executable File

#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER $CGW_DB_USER WITH ENCRYPTED PASSWORD '$CGW_DB_PASSWORD';
CREATE DATABASE $CGW_DB OWNER $CGW_DB_USER;
\c $CGW_DB;
CREATE TABLE infrastructure_groups ( id INT PRIMARY KEY, reserved_size INT, actual_size INT);
CREATE TABLE infras ( mac MACADDR PRIMARY KEY, infra_group_id INT, FOREIGN KEY(infra_group_id) REFERENCES infrastructure_groups(id) ON DELETE CASCADE);
ALTER DATABASE $CGW_DB OWNER TO $CGW_DB_USER;
ALTER TABLE infrastructure_groups OWNER TO $CGW_DB_USER;
ALTER TABLE infras OWNER TO $CGW_DB_USER;
EOSQL