Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

73 rindas
2.0KB

  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. # add avahi suffix
  47. localhostname=$(cat /etc/hostname)
  48. if [ "${localhostname}" != "${host}" ]; then
  49. host=${host}.local
  50. fi
  51. container=$(ssh $host 'docker ps | grep '${SERVICE}' | cut -f1 -d" "')
  52. #echo Container=$container
  53. if [ -z $container ]; then
  54. echo "Qué me estás container?!";
  55. continue;
  56. fi
  57. #NC_IP=$(ssh $host "docker exec ${container} sh -c 'ifconfig eth1' | grep 'inet ' | cut -d':' -f 2 | cut -d' ' -f 1")
  58. curl http://${host}/index.nginx-debian.html 2>/dev/null | grep title | grep Welcome 1>/dev/null;
  59. NC_UP=$((1 - $?));
  60. done;
  61. ./letsencrypt.sh ${STACK_NAME}