You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.1 KiB

  1. #!/bin/bash
  2. ## Installing base docker-host
  3. wget http://docker.0k.io/get/ -qO - | bash
  4. ## shlib is now available
  5. . /etc/shlib || {
  6. echo "shlib is not available. Bailing out." >&2
  7. exit 1
  8. }
  9. set -e
  10. if ! [ -d "/opt/apps/pandachi-deploy" ]; then
  11. mkdir -p /opt/apps && cd /opt/apps
  12. git clone git.0k.io:/var/git/0k/pandachi-deploy.git
  13. fi
  14. #[ -e /etc/compose.conf ] || ln -sfv /opt/apps/pandachi-deploy/etc/compose.conf /etc/compose.conf
  15. ## XXXvlab: should get rid of this file in some future
  16. cd /opt/apps/pandachi-deploy
  17. if ! grep "^DEFAULT_COMPOSE_FILE=$PWD/compose.yml$" /etc/compose/local.conf >/dev/null 2>&1; then
  18. echo "Adding CWD=$PWD to docker-compose."
  19. cat <<EOF >> /etc/compose/local.conf
  20. DEFAULT_COMPOSE_FILE=$PWD/compose.yml
  21. EOF
  22. fi
  23. #type -t docker-compose || ln -sfv /opt/apps/compose/bin/docker-compose /usr/local/bin
  24. type -t docker-clean || ln -sfv /opt/apps/0k-docker/bin/docker-clean /usr/local/bin
  25. if [ -d "/opt/apps/0k-docker" ]; then ## should come from http://docker.0k.io/get/
  26. (
  27. cd /opt/apps/0k-docker
  28. git checkout master
  29. )
  30. fi
  31. echo "Login into our server."
  32. docker login -u deploy -p deployinvm git.panda-chi.io:5002
  33. cd /opt/apps/pandachi-deploy
  34. cat <<EOF > /root/.pgm.rc
  35. prefix_pg_local_command=" " ## otherwise, will default to sudo -u postgres
  36. pgpass="/srv/datastore/data/postgres/var/lib/postgresql/data/pgpass"
  37. [ -f "$pgpass" ] || {
  38. echo "No '$pgpass' found. Postgres database doesn't seem to be setup." >&2
  39. exit 1
  40. }
  41. cp "$pgpass" /root/.pgpass
  42. PGUSER=postgres
  43. PGHOST=$(docker-ip | grep postgres | xargs echo | cut -f 3 -d " ") || {
  44. echo "No local running postgres docker found." >&2
  45. exit 1
  46. }
  47. export PGHOST PGUSER
  48. EOF
  49. if [ "$DOMAIN" ]; then
  50. sed -ri "s/^(\s+domain:\s+).*$/\1$DOMAIN/g" compose.yml
  51. fi
  52. if [ "$MAIN_PASSWORD" ]; then
  53. sed -ri "s/^(\s+admin-password:\s+).*$/\1$MAIN_PASSWORD/g" compose.yml
  54. fi
  55. pip install ovh
  56. ln -sf /opt/apps/pandachi-deploy/bin/* /usr/local/bin/
  57. #compose --debug up odoo apache
  58. ## Marker to probe if this script finished it's job
  59. echo "done" > /var/run/pandachi-installer.0k.io.state