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.

44 lines
1.8 KiB

  1. #!/bin/bash
  2. set -e
  3. KEY=$(relation-get secret) || true
  4. if [ -z "$KEY" ]; then
  5. KEY=$(gen_password 64)
  6. fi
  7. ## XXXvlab: we really need to have a state based cache thingy, because
  8. ## setting the same password each time is really time consumming.
  9. compose --no-relations --no-init \
  10. occ "$MASTER_TARGET_SERVICE_NAME" \
  11. app:install onlyoffice \; \
  12. config:system:set onlyoffice DocumentServerInternalUrl --value="http://$MASTER_BASE_SERVICE_NAME/" \; \
  13. config:system:set onlyoffice StorageUrl --value="http://$MASTER_TARGET_SERVICE_NAME/" \; \
  14. config:app:set onlyoffice jwt_secret --value="$KEY" \; \
  15. config:system:set allow_local_remote_servers --type=boolean --value=true
  16. ONLYOFFICE_CFG="$SERVICE_CONFIGSTORE/etc/onlyoffice/documentserver/local.json"
  17. out=$(jq ".services.CoAuthoring.token.enable.browser = true |
  18. .services.CoAuthoring.token.enable.request.inbox = true |
  19. .services.CoAuthoring.token.enable.request.outbox = true |
  20. .services.CoAuthoring.secret.inbox.string = \"$KEY\" |
  21. .services.CoAuthoring.secret.outbox.string = \"$KEY\" |
  22. .services.CoAuthoring.secret.session.string = \"$KEY\"" \
  23. "$ONLYOFFICE_CFG")
  24. H1=$(cat "$ONLYOFFICE_CFG" | hash_get)
  25. H2=$(echo "$out" | hash_get)
  26. if [ "$H1" != "$H2" ]; then
  27. echo "$out" > "$ONLYOFFICE_CFG"
  28. ## XXXvlab: onlyoffice need to be restarted if already running and local.json changed.
  29. ## it is about docker exec $SERVICE_NAME supervisor restart ...
  30. for container_id in $(get_running_containers_for_service "$SERVICE_NAME"); do
  31. ## restarting all as documented here: https://api.onlyoffice.com/editors/signature/
  32. docker exec "$container_id" supervisorctl restart all
  33. done
  34. relation-set secret "$KEY"
  35. fi