zcubbs / pgc

🌱 pgc is a CLI that automates the initialization process of a PostgreSQL database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

tag Go Version GoDoc Lint Scan Build Status Go Report Card Contributors License

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

  1. 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.

About

🌱 pgc is a CLI that automates the initialization process of a PostgreSQL database.

License:MIT License


Languages

Language:Go 74.5%Language:Shell 16.0%Language:Dockerfile 9.5%