39 lines
1.2 KiB

  1. #!/bin/bash
  2. ## Should be executable N time in a row with same result.
  3. . lib/common
  4. set -e
  5. ## if I'm not linked to a cyclos-server, then complain
  6. if read-0 ts _ _ < <(get_service_relation "$SERVICE_NAME" "cyclos-server"); then
  7. debug "cyclos-server relation fullfilled"
  8. if read-0 wps wpcfg _ < <(get_service_relation "$ts" "web-proxy"); then
  9. debug "found web-proxy relation"
  10. else
  11. ## XXXvlab: relation dependence as this one could actually be implemented in compose-core
  12. err "cyclos-server relation requires the server to have a web-proxy relation to be set"
  13. exit 1
  14. fi
  15. web_proxy_relation_dir=$(get_relation_data_dir "$ts" "$wps" "web-proxy") || {
  16. err "Failed to find relation file"
  17. exit 1
  18. }
  19. web_proxy_relation_config=$(cat "$web_proxy_relation_dir/data") || exit 2
  20. url=$(e "$web_proxy_relation_config" | shyaml get-value url) || {
  21. err "Couldn't get domain information in ${DARKCYAN}web-proxy${NORMAL} relation's data."
  22. exit 1
  23. }
  24. if ! cyclos_ui.conf_add "apiRoot: $url/api"; then
  25. err "Couldn't configure api root correctly."
  26. exit 1
  27. fi
  28. fi
  29. cyclos_ui.generate_website