Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

67 строки
1.7 KiB

  1. #! /bin/sh
  2. set -e
  3. BASE_URL=${BASE_URL:-/}
  4. NGINX_ROOT=/usr/share/nginx/html
  5. INDEX_FILE=$NGINX_ROOT/index.html
  6. NGINX_CONF=/etc/nginx/nginx.conf
  7. node /usr/share/nginx/configurator $INDEX_FILE
  8. replace_in_index () {
  9. if [ "$1" != "**None**" ]; then
  10. sed -i "s|/\*||g" $INDEX_FILE
  11. sed -i "s|\*/||g" $INDEX_FILE
  12. sed -i "s|$1|$2|g" $INDEX_FILE
  13. fi
  14. }
  15. replace_or_delete_in_index () {
  16. if [ -z "$2" ]; then
  17. sed -i "/$1/d" $INDEX_FILE
  18. else
  19. replace_in_index $1 $2
  20. fi
  21. }
  22. if [[ "${BASE_URL}" != "/" ]]; then
  23. sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
  24. fi
  25. replace_in_index myApiKeyXXXX123456789 $API_KEY
  26. if [ "$SWAGGER_JSON_URL" ]; then
  27. sed -i "s|https://petstore.swagger.io/v2/swagger.json|$SWAGGER_JSON_URL|g" $INDEX_FILE
  28. sed -i "s|http://example.com/api|$SWAGGER_JSON_URL|g" $INDEX_FILE
  29. fi
  30. if [[ -f "$SWAGGER_JSON" ]]; then
  31. cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
  32. REL_PATH="./$(basename $SWAGGER_JSON)"
  33. if [[ -z "$SWAGGER_ROOT" ]]; then
  34. SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
  35. fi
  36. if [[ "$BASE_URL" != "/" ]]
  37. then
  38. BASE_URL=$(echo $BASE_URL | sed 's/\/$//')
  39. sed -i \
  40. "s|#SWAGGER_ROOT|rewrite ^$BASE_URL(/.*)$ \$1 break;\n #SWAGGER_ROOT|" \
  41. $NGINX_CONF
  42. fi
  43. sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT/;|g" $NGINX_CONF
  44. sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
  45. sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
  46. fi
  47. # replace the PORT that nginx listens on if PORT is supplied
  48. if [[ -n "${PORT}" ]]; then
  49. sed -i "s|8080|${PORT}|g" $NGINX_CONF
  50. fi
  51. find $NGINX_ROOT -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;
  52. exec nginx -g 'daemon off;'