Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

79 lines
1.9KB

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