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.
- A running PostgreSQL instance.
- A user with
CREATEDBandCREATEROLEprivileges. - A user with
LOGINprivileges.
curl -sfL https://raw.githubusercontent.com/zcubbs/pgc/main/install.sh | bashpgc -c config.yamlEdit 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 thepg_hba.conffile.restart_cmd: Command to restart the PostgreSQL service.
- Build the Docker image:
docker build -t pgc . && docker run --rm --name pgc -p 5432:5432 pgcthe test config file config.yaml will be used.
HuB is licensed under the MIT license.