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.

25 lines
1007 B

  1. #!/bin/bash
  2. set -e
  3. DOMAIN=$(relation-get domain) || exit 1
  4. URL="$(relation-get url)" || exit 1
  5. PROTO="${URL%%://*}"
  6. trusted_domains="$(
  7. compose -q --no-relations --no-init occ "$MASTER_BASE_SERVICE_NAME" \
  8. config:system:get trusted_domains)"
  9. occ_opts=(
  10. ## necessary as nextcloud do not detect correctly those, and behind
  11. ## a proxy, it will generate a lot of URL that are not detected
  12. ## by means of ``ReverseProxyPass`` on apache for instance
  13. config:system:set overwritehost --value="$DOMAIN" \;
  14. config:system:set overwriteprotocol --value="$PROTO"
  15. )
  16. if ! [[ "$'\n'$trusted_domains$'\n'" == *"$'\n'$MASTER_BASE_SERVICE_NAME$'\n'"* ]]; then
  17. trusted_index=$(echo "$trusted_domains" | wc -l)
  18. debug "Adding $MASTER_TARGET_SERVICE_NAME to ${WHITE}trusted_domains${NORMAL}."
  19. occ_opts+=( \; config:system:set trusted_domains "$trusted_index" --value="$MASTER_BASE_SERVICE_NAME")
  20. fi
  21. compose --no-relations --no-init occ "$MASTER_BASE_SERVICE_NAME" "${occ_opts[@]}"