Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- # Edit the following to change the name of the database user that will be created:
- APP_DB_USER=ubuntu
- APP_DB_PASS=ubuntu
- # Edit the following to change the name of the database that is created
- APP_DB_NAME=djangoandroid
- # Edit the following to change the version of PostgreSQL that is installed
- PG_VERSION=9.5
- # Update package list and upgrade all packagesini
- apt-get update
- apt-get -y upgrade
- ## install packages for postgres + python3
- apt-get -y install "postgresql-$PG_VERSION" "postgresql-contrib-$PG_VERSION"
- apt-get -y install vim git python3-setuptools python3-dev libpq-dev libsasl2-dev build-essential virtualenv
- PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
- PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
- PG_DIR="/var/lib/postgresql/$PG_VERSION/main"
- # Edit postgresql.conf to change listen address to '*':
- sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
- # Append to pg_hba.conf to add password auth:
- echo "host all all all md5" >> "$PG_HBA"
- # Explicitly set default client_encoding
- echo "client_encoding = utf8" >> "$PG_CONF"
- # generate locales
- locale-gen de_DE.UTF-8
- update-locale LANG=de_DE.UTF-8
- # Restart so that all new config is loaded:
- service postgresql restart
- update-rc.d postgresql enable
- cat << EOF | su - postgres -c psql
- -- Create the database user:
- CREATE USER $APP_DB_USER WITH PASSWORD '$APP_DB_PASS';
- ALTER USER $APP_DB_USER CREATEDB; # important for django test db
- ALTER ROLE $APP_DB_USER SUPERUSER;
- -- Create the database:
- CREATE DATABASE $APP_DB_NAME WITH OWNER=$APP_DB_USER
- LC_COLLATE='de_DE.UTF-8'
- LC_CTYPE='de_DE.UTF-8'
- ENCODING='UTF8'
- TEMPLATE=template0;
- EOF
Add Comment
Please, Sign In to add comment