aboutsummaryrefslogtreecommitdiff
path: root/getmepostgres.sh
blob: 50976f8766da09e8daad69352f9054a66125e4b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

echo "> Checking for postgres at ~/pg";
if [ -d "~/pg" ]; then
  echo "Postgres Directory exists, nevermind...";
  exit 1;
fi

echo " ";
echo " ";
echo " ";
echo "This installation process takes ~3:50 minutes to complete.";
echo " ";
echo " ";
echo " ";
sleep 3;

echo "> Making postgres directory at ~/pg";
mkdir ~/pg;
currentDir=$(pwd);

echo "> Chaning dir to ~/pg";
cd ~/pg;

echo "> Cloning Repo";
git clone https://github.com/postgres/postgres.git;

echo "> Checking out to version 10.1";
cd ./postgres;
git reset --hard REL_10_1;

echo "> Configuring";
./configure --prefix=$HOME/pg/postgres/ --with-python PYTHON=/usr/bin/python2.7;

echo "> Building Postgres";
make -j 5;

echo "> Installing Postgres";
make install;

echo "> Initialise the Database";
~/pg/postgres/bin/initdb -D ~/pg/postgres/data/;
echo " ";
echo " ";
echo " ";
echo " ";
echo "> Starting the postgres server";
~/pg/postgres/bin/pg_ctl -D ~/pg/postgres/data/ -l POSTGRES_logfile start;
echo "> Create the Database";
~/pg/postgres/bin/createdb be4;
echo "> Creating Admin user";
~/pg/postgres/bin/psql -U ${USER} postgres -c "CREATE USER admin WITH PASSWORD 'eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af';";
echo "> Granting Admin Permissions";
~/pg/postgres/bin/psql -U ${USER} postgres -c "ALTER DATABASE be4 OWNER TO admin;";


echo " ";
echo " ";
echo " ";
echo " ";
echo " ";
echo "> Completed the installation of Postgres.";
cd $currentDir;