Guest User

Untitled

a guest
Nov 25th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #!/bin/sh -e
  2. # Edit the following to change the name of the database user that will be created:
  3. APP_DB_USER=ubuntu
  4. APP_DB_PASS=ubuntu
  5. # Edit the following to change the name of the database that is created
  6. APP_DB_NAME=djangoandroid
  7. # Edit the following to change the version of PostgreSQL that is installed
  8. PG_VERSION=9.5
  9. # Update package list and upgrade all packagesini
  10. apt-get update
  11. apt-get -y upgrade
  12. ## install packages for postgres + python3
  13. apt-get -y install "postgresql-$PG_VERSION" "postgresql-contrib-$PG_VERSION"
  14. apt-get -y install vim git python3-setuptools python3-dev libpq-dev libsasl2-dev build-essential virtualenv
  15. PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
  16. PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
  17. PG_DIR="/var/lib/postgresql/$PG_VERSION/main"
  18. # Edit postgresql.conf to change listen address to '*':
  19. sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
  20. # Append to pg_hba.conf to add password auth:
  21. echo "host all all all md5" >> "$PG_HBA"
  22. # Explicitly set default client_encoding
  23. echo "client_encoding = utf8" >> "$PG_CONF"
  24. # generate locales
  25. locale-gen de_DE.UTF-8
  26. update-locale LANG=de_DE.UTF-8
  27. # Restart so that all new config is loaded:
  28. service postgresql restart
  29. update-rc.d postgresql enable
  30. cat << EOF | su - postgres -c psql
  31. -- Create the database user:
  32. CREATE USER $APP_DB_USER WITH PASSWORD '$APP_DB_PASS';
  33. ALTER USER $APP_DB_USER CREATEDB; # important for django test db
  34. ALTER ROLE $APP_DB_USER SUPERUSER;
  35. -- Create the database:
  36. CREATE DATABASE $APP_DB_NAME WITH OWNER=$APP_DB_USER
  37. LC_COLLATE='de_DE.UTF-8'
  38. LC_CTYPE='de_DE.UTF-8'
  39. ENCODING='UTF8'
  40. TEMPLATE=template0;
  41. EOF
Add Comment
Please, Sign In to add comment