#!/usr/bin/env bash

# Script designed to ensure the VIP is removed, block all non-superuser
# connections to any database, and then shut down the database service.
# This will prevent applications from communicating with the node until
# an investigation can revert the connection limit and start PostgreSQL.

VIP=10.0.30.50
IFACE=eth0
PATH=/usr/pgsql-12/bin:$PATH
VIP_CONF="${VIP}/32 dev ${IFACE} label ${IFACE}:pg"

sudo /sbin/ip addr del ${VIP_CONF}

psql -c "UPDATE pg_database SET datconnlimit=0;" postgres

sudo systemctl stop postgresql@12-main

exit 0
