Skip to content

Instantly share code, notes, and snippets.

@adilsoncarvalho
Last active December 31, 2015 04:09
Show Gist options
  • Save adilsoncarvalho/7932400 to your computer and use it in GitHub Desktop.
Save adilsoncarvalho/7932400 to your computer and use it in GitHub Desktop.
Installing Postgresql-9.3 on Ubuntu (10.04 or 12.04)
#!/bin/bash
#
# As seen at http://www.postgresql.org/download/linux/ubuntu/
#
REPO_FILE=/etc/apt/sources.list.d/pgdg.list
UBUNTU_VERSION=$(lsb_release -sr)
if [[ $UBUNTU_VERSION -eq '12.04' ]]; then
echo ' * Using defaults for 12.04 (Precise)'
UBUNTU_VERSION='precise'
elif [[ $UBUNTU_VERSION -eq '10.04' ]]; then
echo ' * Using defaults for 10.04 (Lucid)'
UBUNTU_VERSION='lucid'
elif
echo " ! This Ubuntu version is not supported by this script ($UBUNTU_VERSION)"
exit 1
fi
if [[ ! -f $REPO_FILE ]]; then
touch $REPO_FILE
fi
REPOSITORY="deb http://apt.postgresql.org/pub/repos/apt/ $UBUNTU_VERSION-pgdg main"
if [[ -z $(grep $REPOSITORY $REPO_FILE) ]]; then
echo $REPOSITORY >> $REPO_FILE
end
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
apt-get update
apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 postgresql-doc-9.3
echo " * DONE!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment