This script automates the installation and uninstallation of PostgreSQL on Ubuntu systems, along with an optional extension, pgvector. It simplifies the PostgreSQL setup process, configuring the server to listen on all IP addresses and managing user roles with superuser privileges. Specifically designed for Ubuntu, this script is also suitable for other Debian-based distributions that use apt-get
for package management.
Developed by Sonny Mir.
This script is released under the MIT License.
- Install PostgreSQL: Sets up PostgreSQL and its contrib packages, starts and enables the service, configures the server to listen on all IP addresses, and creates a superuser with specified credentials.
- Optional pgvector Extension: Offers the option to install the pgvector extension, enhancing PostgreSQL with vector database capabilities.
- Uninstall PostgreSQL: Removes PostgreSQL and all associated data and configurations.
To use the script, run it with one of the following commands depending on the desired operation:
./install_postgress.sh install - Installs PostgreSQL and prompts whether to install the pgvector extension.`
./install_postgress.sh uninstall - Completely removes PostgreSQL and all its configurations.`
`./install_postgress help - Displays usage information.`
- Updates the package list.
- Installs PostgreSQL and its contrib packages.
- Starts and enables PostgreSQL service.
- Prompts for the superuser username and password (credentials are entered in a secure manner without displaying the password).
- Sets up PostgreSQL to accept connections on all network interfaces.
- Optionally installs the pgvector extension if the user agrees.
- Stops the PostgreSQL service.
- Purges PostgreSQL packages and their dependencies.
- Removes obsolete packages to clean up the system.
- The script is intended for use on systems running Ubuntu or other Debian-based distributions that use
apt-get
for package management. - Administrative (sudo) privileges are required to install and remove software packages.
- This script should be run from a directory that the executing user has permissions to access, or it may result in permission errors.
- Ensure that you have internet access and your package lists are up to date to avoid errors during package installation.
Written for all my brothers and sisters ❤️.