Update Postgres uninstaller

This commit is contained in:
Edi Septriyanto
2023-04-10 08:56:39 +07:00
parent 4c24be0688
commit 1eff5f8fa8

View File

@@ -65,16 +65,8 @@ function init_postgres_removal() {
if dpkg-query -l | awk '/postgresql/ { print $2 }' | grep -qwE "^postgresql"; then
echo "Found PostgreSQL ${POSTGRES_VERSION} packages installation, removing..."
# Installed Postgres packages.
if [[ "${POSTGRES_VERSION}" == "latest" || "${POSTGRES_VERSION}" == "stable" ]]; then
POSTGRES_PKGS+=("postgresql" "postgresql-client" "postgresql-client-common" "postgresql-common")
else
POSTGRES_PKGS+=("postgresql-${POSTGRES_VERSION}" "postgresql-client-${POSTGRES_VERSION}" \
"postgresql-client-common" "postgresql-common")
fi
# Remove PostgreSQL server.
run apt-get --purge remove -q -y "${POSTGRES_PKGS[@]}"
# shellcheck disable=SC2046
run apt-get purge -q -y $(dpkg-query -l | awk '/postgresql/ { print $2 }' | grep -wE "^postgresql")
# Remove PostgreSQL default user.
if [[ -n $(getent passwd "${POSTGRES_USER}") ]]; then