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.

43 lines
1.1 KiB

  1. #!/bin/bash
  2. ##
  3. ## Get domain in option of relation "web-proxy"
  4. ##
  5. ## XXXvlab: there is a tiny lapse of time where database is not yet
  6. ## installed, and admin password is the default value.
  7. . lib/common
  8. set -ex
  9. if url=$(named-relation-get "web-proxy" url); then
  10. ## proxy ! so we probably already set up the url in
  11. ## pre_deploy
  12. exit 0
  13. fi
  14. container=$(get_running_containers_for_service "$SERVICE_NAME" | head -n 1)
  15. container_network_ip=$(get_docker_ip "$container")
  16. container_ip=${container_network_ip#*:}
  17. ## XXXvlab: hard written duplicate value
  18. url="$container_ip:8080"
  19. CONTROL_URL_FILE="$SERVICE_DATASTORE/.control-url"
  20. ## Was it already properly propagated to database ?
  21. control_url=$(H "${url}")
  22. if ! [ -e "$CONTROL_URL_FILE" ] || [ "$control_url" != "$(cat "$CONTROL_URL_FILE")" ]; then
  23. ## In ``configurations`` table, columns login_url, logout_url, root_url
  24. if ! sql < <(e "
  25. UPDATE configurations
  26. SET
  27. root_url = 'http://$url'
  28. "); then
  29. debug "Failed to set root url."
  30. exit 1
  31. fi
  32. e "$control_password" > "$CONTROL_URL_FILE"
  33. fi