setup-krb.sh 983 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. function getContainerHealth {
  3. docker inspect --format "{{.State.Health.Status}}" $1
  4. }
  5. function waitContainer {
  6. while STATUS=$(getContainerHealth $1); [ $STATUS != "healthy" ]; do
  7. if [ $STATUS == "unhealthy" ]; then
  8. echo "Failed!"
  9. exit -1
  10. fi
  11. printf .
  12. lf=$'\n'
  13. sleep 1
  14. done
  15. printf "$lf"
  16. }
  17. mkdir /tmp/shared
  18. # start the dc
  19. docker run -dit --name dc -v /tmp/shared:/shared --hostname krb.domain.test --cap-add SYS_ADMIN icewind1991/samba-krb-test-dc
  20. DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}')
  21. waitContainer dc
  22. # start apache
  23. docker run -d --name apache -v $PWD:/var/www/html -v /tmp/shared:/shared --dns $DC_IP --hostname httpd.domain.test icewind1991/samba-krb-test-apache
  24. APACHE_IP=$(docker inspect apache --format '{{.NetworkSettings.IPAddress}}')
  25. # add the dns record for apache
  26. docker exec dc samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1