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
CREATEDB
andCREATEROLE
privileges. - A user with
LOGIN
privileges.
curl -sfL https://raw.githubusercontent.com/zcubbs/pgc/main/install.sh | bash
pgc -c config.yaml
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 thepg_hba.conf
file.restart_cmd
: Command to restart the PostgreSQL service.
- 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.
HuB is licensed under the MIT license.