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.

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