aboutsummaryrefslogtreecommitdiff
path: root/getmepostgres.sh
diff options
context:
space:
mode:
authorTom Harley2018-02-08 18:28:57 +0000
committerTom Harley2018-02-08 18:28:57 +0000
commitd1f88d13f5c60cd0229d4267f92cd4d79f5fbff3 (patch)
treece54ab9c43b611455b658cf2eaf4fc3c5ea71732 /getmepostgres.sh
parentadded literal matching (diff)
parentconfigured server to use pg server on lab machines (diff)
downloadmedicine-d1f88d13f5c60cd0229d4267f92cd4d79f5fbff3.tar.gz
medicine-d1f88d13f5c60cd0229d4267f92cd4d79f5fbff3.zip

Merge branch ‘trh/db-orm’ into trh/payload-checker

Diffstat (limited to 'getmepostgres.sh')
-rwxr-xr-xgetmepostgres.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/getmepostgres.sh b/getmepostgres.sh
new file mode 100755
index 0000000..035b300
--- /dev/null
+++ b/getmepostgres.sh
@@ -0,0 +1,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;