hangar18/images/postgres/prep.sh

27 lines
806 B
Bash
Executable File

#!/bin/bash
# removing the database cluster if it exists and prepping everything for posgresql operation
# be careful, Will Robinson!
# we need to be root for this
if [[ `whoami` != 'root' ]]; then
echo "we need to be root for this, quitting"
exit 1
fi
# work the directory
cd /var/lib/postgresql
chown postgres:postgres ./
chmod 0700 ./
# initdb as postgres
su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres
# config
echo "host any any 172.17.0.0/16 trust" >> /etc/postgresql/9.3/main/pg_hba.conf
# create the needed databases
#/etc/init.d/postgresql start
#su -c 'psql --command "CREATE USER some_user;"' postgres
#su -c "psql --command \"CREATE DATABASE some_db WITH OWNER some_user TEMPLATE template0 ENCODING 'UTF8';\"" postgres
#/etc/init.d/postgresql stop