No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

67 líneas
1.8KB

  1. #!/bin/bash
  2. STACK_NAME=$1
  3. BUILD=$2
  4. if [ -z $BUILD ]; then
  5. BUILD=1;
  6. fi
  7. if [ $# -eq 0 ]; then
  8. echo "You must pass stack name as a parameter"
  9. exit 1
  10. fi
  11. # Delete previous running stack
  12. docker stack rm ${STACK_NAME}
  13. # Build images
  14. if [ $BUILD -eq 1 ]; then
  15. docker-compose build
  16. docker push bingen/rpi-openldap
  17. docker push bingen/rpi-mariadb
  18. docker push bingen/rpi-haproxy
  19. docker push bingen/rpi-mailserver
  20. docker push bingen/rpi-nextcloud
  21. docker push bingen/rpi-zoneminder
  22. fi
  23. # Deploy Stack
  24. # seen here: https://github.com/docker/docker/issues/29133#issuecomment-278198683
  25. env $(cat .env | grep "^[A-Z]" | xargs) \
  26. docker stack deploy --compose-file docker-compose.yml ${STACK_NAME}
  27. echo Wait for services to start
  28. sleep 60
  29. # ##### Add users to LDAP ###### #
  30. ./add_users.sh ${STACK_NAME}
  31. # Add local domains
  32. ./add_dns_entries.sh ${STACK_NAME}
  33. # Wait for Nextcloud
  34. NC_UP=0
  35. while [ $NC_UP -eq 0 ]; do
  36. # TODO: Use docker inspect Go templates
  37. #NC_IP=$(docker network inspect debuen_default | grep -A 3 nextcloud | grep IPv4Address | cut -d':' -f 2 | cut -d'"' -f 2 | cut -d'/' -f 1)
  38. # Find Nextcloud container
  39. SERVICE=nextcloud
  40. host=$(docker stack ps ${STACK_NAME} | grep Running | grep ${SERVICE} | awk '{ print $4 }')
  41. #echo Host=$host
  42. if [ -z $host ]; then
  43. echo "No host found!";
  44. continue;
  45. fi
  46. container=$(ssh $host 'docker ps | grep '${SERVICE}' | cut -f1 -d" "')
  47. #echo Container=$container
  48. if [ -z $container ]; then
  49. echo "Qué me estás container?!";
  50. continue;
  51. fi
  52. #NC_IP=$(ssh $host "docker exec ${container} sh -c 'ifconfig eth1' | grep 'inet ' | cut -d':' -f 2 | cut -d' ' -f 1")
  53. curl http://${host}/index.nginx-debian.html 2>/dev/null | grep title | grep Welcome 1>/dev/null;
  54. NC_UP=$((1 - $?));
  55. done;
  56. ./letsencrypt.sh ${STACK_NAME}