aboutsummaryrefslogtreecommitdiff
path: root/getmepostgres.sh
blob: 035b300bd874e2d19aecb6e66bc21b2108e03ff7 (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
64
#!/bin/bash

PGDIR=${1-"$HOME/pg"}

echo "> Checking for postgres at $PGDIR";
if [ -d "$PGDIR" ]; 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;

echo "> Making postgres directory at $PGDIR";
mkdir -p "$PGDIR";
currentDir=$(pwd);

echo "> Changing dir to $PGDIR";
cd "$PGDIR";

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="$PWD" --with-python PYTHON="/usr/bin/python2.7";

echo "> Building Postgres";
make;

echo "> Installing Postgres";
make install;

echo "> Initialise the Database";
"$PGDIR/postgres/bin/initdb" -D "$PGDIR/postgres/data/";
echo;
echo;
echo;
echo;
echo "> Starting the postgres server";
"$PGDIR/postgres/bin/pg_ctl" -D "$PGDIR/postgres/data/" -l POSTGRES_logfile start;
echo "> Create the Database";
"$PGDIR/postgres/bin/createdb" be4;
echo "> Creating Admin user";
"$PGDIR/postgres/bin/psql" -U ${USER} postgres -c "CREATE USER admin;";
echo "> Granting Admin Permissions";
"$PGDIR/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;