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.3 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  1. #! /bin/sh
  2. set -eo pipefail
  3. replace_in_index () {
  4. if [ "$1" != "**None**" ]; then
  5. sed -i "s|/\*||g" index.html
  6. sed -i "s|\*/||g" index.html
  7. sed -i "s|$1|$2|g" index.html
  8. fi
  9. }
  10. replace_or_delete_in_index () {
  11. if [ -z "$2" ]; then
  12. sed -i "/$1/d" index.html
  13. else
  14. replace_in_index $1 $2
  15. fi
  16. }
  17. replace_in_index myApiKeyXXXX123456789 $API_KEY
  18. replace_or_delete_in_index your-client-id $OAUTH_CLIENT_ID
  19. replace_or_delete_in_index your-client-secret-if-required $OAUTH_CLIENT_SECRET
  20. replace_or_delete_in_index your-realms $OAUTH_REALM
  21. replace_or_delete_in_index your-app-name $OAUTH_APP_NAME
  22. if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
  23. replace_in_index "additionalQueryStringParams: {}" "additionalQueryStringParams: {$OAUTH_ADDITIONAL_PARAMS}"
  24. fi
  25. if [[ -f $SWAGGER_JSON ]]; then
  26. sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" index.html
  27. sed -i "s|http://example.com/api|swagger.json|g" index.html
  28. else
  29. sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" index.html
  30. sed -i "s|http://example.com/api|$API_URL|g" index.html
  31. fi
  32. if [[ -n "$VALIDATOR_URL" ]]; then
  33. sed -i "s|.*validatorUrl:.*$||g" index.html
  34. sed -i "s|\(url: url,.*\)|\1\n validatorUrl: \"${VALIDATOR_URL}\",|g" index.html
  35. fi
  36. exec http-server -p $PORT $*