pgc PostgreSQL Initializer
pgc is a CLI that automates the initialization process of a PostgreSQL database. It creates users, databases, assigns privileges, updates the pg_hba.conf file, and restarts the PostgreSQL service.

Prerequisites
- A running PostgreSQL instance.
- A user with
CREATEDB and CREATEROLE privileges.
- A user with
LOGIN privileges.
Installation
curl -sfL https://raw.githubusercontent.com/zcubbs/pgc/main/install.sh | bash
Usage
pgc -c config.yaml
Configuration
Edit the config.yaml file to set up the PostgreSQL configurations, users, databases, and privileges. Below are the configurable sections:
postgresql: PostgreSQL connection details such as host, port, user, and password.
databases: List of databases to be created along with their owners.
users: List of users to be created along with their passwords.
privileges: Privileges to be granted to users on specific databases.
pg_hba: pg_hba configuration details.
pg_hba_conf_path: Path to the pg_hba.conf file.
restart_cmd: Command to restart the PostgreSQL service.
Development
Prerequisites
Run Test Using Docker
- Build the Docker image:
docker build -t pgc . && docker run --rm --name pgc -p 5432:5432 pgc
the test config file config.yaml will be used.
License
HuB is licensed under the MIT license.