fork 0k-charms
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.7 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. ONLYOFFICE_CFG="$SERVICE_CONFIGSTORE/etc/onlyoffice/documentserver/local.json"
  16. out=$(jq ".services.CoAuthoring.token.enable.browser = true |
  17. .services.CoAuthoring.token.enable.request.inbox = true |
  18. .services.CoAuthoring.token.enable.request.outbox = true |
  19. .services.CoAuthoring.secret.inbox.string = \"$KEY\" |
  20. .services.CoAuthoring.secret.outbox.string = \"$KEY\" |
  21. .services.CoAuthoring.secret.session.string = \"$KEY\"" \
  22. "$ONLYOFFICE_CFG")
  23. H1=$(cat "$ONLYOFFICE_CFG" | hash_get)
  24. H2=$(echo "$out" | hash_get)
  25. if [ "$H1" != "$H2" ]; then
  26. echo "$out" > "$ONLYOFFICE_CFG"
  27. ## XXXvlab: onlyoffice need to be restarted if already running and local.json changed.
  28. ## it is about docker exec $SERVICE_NAME supervisor restart ...
  29. for container_id in $(get_running_containers_for_service "$SERVICE_NAME"); do
  30. ## restarting all as documented here: https://api.onlyoffice.com/editors/signature/
  31. docker exec "$container_id" supervisorctl restart all
  32. done
  33. relation-set secret "$KEY"
  34. fi