Last active
October 13, 2015 12:27
-
-
Save pratyakshs/b03e4afdcb9431d940b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURDIR=`pwd`; | |
# Add any other dependencies that you may find | |
sudo apt-get update; | |
sudo apt-get install -y git eclipse eclipse-cdt flex bison zlib1g-dev libreadline6-dev; | |
# Makes a shallow clone of REL9_4_STABLE branch from postgres' github mirror | |
git clone https://github.com/postgres/postgres.git --branch REL9_4_STABLE --single-branch --depth 1; | |
REPO_NAME=postgres; | |
mkdir -p $CURDIR/$REPO_NAME/install; | |
# Potentially dangerous | |
# Removes all the lines containing POSTGRES_INSTALLDIR or POSTGRES_SRCDIR or PGDATA from ~/.bashrc | |
grep -v "POSTGRES_INSTALLDIR" ~/.bashrc | grep -v "POSTGRES_SRCDIR" | grep -v "PGDATA" > ~/.bashrc.v01; | |
mv ~/.bashrc.v01 ~/.bashrc; | |
# Adds these exports to ~/.bashrc | |
STR1="export POSTGRES_INSTALLDIR=$CURDIR/$REPO_NAME/install" | |
STR2="export POSTGRES_SRCDIR=$CURDIR/$REPO_NAME/" | |
echo $STR1 >> ~/.bashrc; | |
echo $STR2 >> ~/.bashrc; | |
# Sets environment variables | |
${STR1}; | |
${STR2}; | |
cd ${POSTGRES_SRCDIR}; | |
# Installation with debugging enabled | |
./configure --prefix=${POSTGRES_INSTALLDIR} --enable-debug; | |
export enable_debug=yes; | |
make | tee make.out | |
make install | tee make_install.out | |
# Adds these exports to ~/.bashrc | |
STR3="export LD_LIBRARY_PATH=${POSTGRES_INSTALLDIR}/lib:\$LD_LIBRARY_PATH"; | |
STR4="export PATH=${POSTGRES_INSTALLDIR}/bin:\$PATH"; | |
STR5="export PGDATA=${POSTGRES_INSTALLDIR}/data"; | |
echo $STR3 >> ~/.bashrc; | |
echo $STR4 >> ~/.bashrc; | |
echo $STR5 >> ~/.bashrc; | |
# Sets up environment variables | |
export LD_LIBRARY_PATH=${POSTGRES_INSTALLDIR}/lib:$LD_LIBRARY_PATH; | |
export PATH=${POSTGRES_INSTALLDIR}/bin:$PATH; | |
${STR5}; | |
# Creates a new PostgreSQL database cluster | |
${POSTGRES_INSTALLDIR}/bin/initdb -D ${PGDATA}; | |
# Runs the PostgreSQL server | |
${POSTGRES_INSTALLDIR}/bin/postmaster -D $PGDATA > logfile 2>&1 & | |
sleep 2; | |
# Creates a test database | |
${POSTGRES_INSTALLDIR}/bin/createdb -p 5432 test; | |
${POSTGRES_INSTALLDIR}/bin/pg_ctl stop; | |
# Restores working directory | |
cd -; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment