000_check_missing_secrets.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. set -e
  3. REQUIRED_SECRETS="
  4. OVERLEAF_INVITE_TOKEN_SECRET
  5. "
  6. MISSING_ITEMS=""
  7. for name in ${REQUIRED_SECRETS}; do
  8. if [[ -z "${!name}" ]]; then
  9. MISSING_ITEMS="$MISSING_ITEMS $name"
  10. fi
  11. done
  12. if [[ "$MISSING_ITEMS" == "" ]]; then
  13. exit 0
  14. fi
  15. MISSING_ITEMS=$(echo "$MISSING_ITEMS" | xargs -n1 | sed 's/^/ - /')
  16. N=$(echo "$MISSING_ITEMS" | wc -l)
  17. cat <<EOF
  18. ------------------------------------------------------------------------
  19. Missing required secrets
  20. ------------------------
  21. Your configuration is missing $N required secret(s):
  22. $MISSING_ITEMS
  23. These secrets must be set to persistent random values and kept
  24. stable across container restarts and upgrades. Regenerating them
  25. will invalidate previously issued tokens stored in the database.
  26. Generate a value with, for example:
  27. openssl rand -base64 32
  28. Overleaf toolkit setups:
  29. Add the missing variable(s) to config/variables.env and restart:
  30. github.com/overleaf/toolkit$ bin/up
  31. docker compose setups:
  32. Add the missing variable(s) to the sharelatex service environment
  33. in docker-compose.yml (or your override file) and restart.
  34. Refusing to startup, exiting in 10s.
  35. ------------------------------------------------------------------------
  36. EOF
  37. sleep 10
  38. exit 101