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.

32 lines
1.3 KiB

  1. #!/bin/bash
  2. set -e
  3. DOMAIN=$(relation-get domain) || exit 1
  4. URL="$(relation-get url)" || exit 1
  5. PROTO="${URL%%://*}"
  6. if ! trusted_domains="$(
  7. compose -q --no-relations --no-init occ "$MASTER_BASE_SERVICE_NAME" \
  8. config:system:get trusted_domains)"; then
  9. err "Couldn't get 'trusted_domains'. Here's the ouput:"
  10. echo "$trusted_domains" | prefix " | " >&2
  11. echo "If the code of nextcloud is already there (command occ is found), but " >&2
  12. echo "the database is not yet created, this situation will arise." >&2
  13. exit 1
  14. fi
  15. occ_opts=(
  16. ## necessary as nextcloud do not detect correctly those, and behind
  17. ## a proxy, it will generate a lot of URL that are not detected
  18. ## by means of ``ReverseProxyPass`` on apache for instance
  19. config:system:set overwritehost --value="$DOMAIN" \;
  20. config:system:set overwriteprotocol --value="$PROTO"
  21. )
  22. if ! [[ $'\n'"$trusted_domains"$'\n' == *$'\n'"$MASTER_BASE_SERVICE_NAME"$'\n'* ]]; then
  23. trusted_index=$(echo "$trusted_domains" | wc -l)
  24. debug "Adding $MASTER_TARGET_SERVICE_NAME to ${WHITE}trusted_domains${NORMAL}."
  25. occ_opts+=( \; config:system:set trusted_domains "$trusted_index" --value="$MASTER_BASE_SERVICE_NAME")
  26. fi
  27. compose --no-relations --no-init occ "$MASTER_BASE_SERVICE_NAME" "${occ_opts[@]}"