Created
September 15, 2021 09:59
-
-
Save anurag-roy/4557a8be0a45cd0e19e454ab7acad06b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Postgres if not exists | |
which psql | |
if [ "$?" -ne 0 ] | |
then | |
echo "Installing Postgres..." | |
sudo apt-get install postgresql --yes | |
echo "Altering password for user 'postgres'" | |
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';" | |
else | |
echo "Postgres is installed. Skipping installation..." | |
fi | |
# Uninstall postgresql | |
sudo apt-get --purge remove $(dpkg -l | grep postgres | awk '{ ORS = " " } {print $2}') --yes | |
# Delete 'postgres' user | |
sudo deluser postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment