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.

40 lines
1.0 KiB

  1. #!/bin/bash
  2. set -e
  3. version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
  4. ## bug: https://github.com/adoptium/containers/issues/215#issuecomment-1142046045
  5. docker_version=$(docker info --format '{{.ServerVersion}}')
  6. if ! version_gt "$docker_version" 20.10.0; then
  7. err "Sorry, $SERVICE_NAME require docker version >= 20.10 (current: $docker_version)"
  8. exit 1
  9. fi
  10. PASSWORD_FILE="$SERVICE_DATASTORE"/secret-password
  11. if ! [ -f "$PASSWORD_FILE" ]; then
  12. info "Generating secret password"
  13. mkdir -p "${PASSWORD_FILE%/*}"
  14. umask 077
  15. openssl rand -base64 32 > "$PASSWORD_FILE"
  16. else
  17. info "Using existing secret password"
  18. fi
  19. secret_password=$(cat "$PASSWORD_FILE")
  20. support_email=$(options-get support-email)
  21. allowed_emails=$(options-get allowed-emails "") || true
  22. if [ -z "$allowed_emails" ]; then
  23. allowed_emails="*"
  24. fi
  25. init-config-add "\
  26. $MASTER_BASE_SERVICE_NAME:
  27. environment:
  28. SECRET_PASSWORD: \"$secret_password\"
  29. SUPPORT_EMAIL: \"$support_email\"
  30. ALLOWED_EMAILS: \"$allowed_emails\"
  31. "