55 lines
1.4 KiB

  1. #!/bin/bash
  2. set -eux # -x for verbose logging to juju debug-log
  3. ## 0k git remote options
  4. GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
  5. ## 0k git remote path
  6. GIT_0K_BASE=${GIT_0K_BASE:-"git.0k.io:/var/git"}
  7. apt-get install -y --force-yes cron kal-scripts
  8. if [ "$(lsb_release -c -s)" == "trusty" ]; then
  9. apt-get install -y --force-yes postgresql-9.3
  10. else
  11. apt-get install -y --force-yes postgresql-9.1
  12. fi
  13. cat <<EOF > /etc/cron.d/pgbackup
  14. SHELL=/bin/sh
  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. 32 1 * * * root ansi_colors=no dayold=2 nbold=5 pgdump_to_dir /var/backups
  17. EOF
  18. ##
  19. ## Install 0k-manage for all the pg_* tools
  20. ##
  21. (
  22. if ! [ -d "/opt/apps/0k-manage" ]; then
  23. cd /opt/apps &&
  24. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" &&
  25. cd /opt/apps/0k-manage &&
  26. git checkout 0k/prod/master
  27. fi
  28. ln -sf /opt/apps/0k-manage/src/bin/* /usr/local/bin/
  29. )
  30. ## XXXvlab: Shouldn't we use ldap to create a key for each client and
  31. ## remove the clear password from here ?
  32. #echo "CREATE USER openerp WITH PASSWORD 'xxxx' CREATEDB NOCREATEROLE;" | sudo -u postgres psql
  33. ## add this to pghba
  34. #host all all 172.32.0.0/12 md5
  35. #host all all 172.33.0.0/12 md5
  36. ## modify listen_addresses in postgresql.conf
  37. #listen_addresses='*'