#!/bin/bash
#

#***********************************************************************
# First time install:
#***********************************************************************
echo
echo "---: ADDING USER 'postgres' WITH PASSWORD 'postgres' :---"
echo
useradd -m postgres -s /bin/bash && autopasswd postgres postgres postgres

echo
echo "---: MAKING 'postgres' OWNER OF DB DIRECTORY :---"
echo
mkdir /home/postgres/pgdata && chown postgres:users /home/postgres/pgdata

echo
echo "---: INITIALIZING DEFAULT DATABASE CLUSTER :---"
echo
sudo -u postgres /opt/postgresql/bin/initdb -D /home/postgres/pgdata

echo
echo "---: DELETING THIS MENU OPTION :---"
echo
rm /usr/share/applications/Postgresql/pg-first-run.desktop
rm /opt/kde/share/applnk/Development/PostgreSQL/Configuration/pg-first-run.desktop

echo
echo "---: POST-INSTALL SCRIPT HAS FINISHED :---"
echo "---: CLOSE THIS TERMINAL AFTER READING SCRIPT RESULTS :---"
echo
