run.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. set -xe
  3. echo '
  4. {
  5. "host": "0.0.0.0",
  6. "port": 7777,
  7. "keyLength": 6,
  8. "maxLength": 400000,
  9. "staticMaxAge": 86400,
  10. "recompressStaticAssets": true,
  11. "logging": [
  12. {
  13. "level": "verbose",
  14. "type": "Console",
  15. "colorize": true
  16. }
  17. ],
  18. "keyGenerator": {
  19. "type": "random"
  20. },
  21. "rateLimits": {
  22. "categories": {
  23. "normal": {
  24. "totalRequests": 500,
  25. "every": 60000
  26. }
  27. }
  28. },
  29. "documents": {
  30. "about": "/hastebin/about.md",
  31. "haste": "/hastebin/haste.py"
  32. },
  33. ' > config.js
  34. if [ "$STORAGE_TYPE" = "file" ]
  35. then
  36. echo '
  37. "storage": {
  38. "path": "/hastebin/data",
  39. "type": "file"
  40. }
  41. ' >> config.js
  42. fi
  43. if [ "$STORAGE_TYPE" = "redis" ]
  44. then
  45. npm install redis
  46. echo '
  47. "storage": {
  48. "type": "redis",
  49. "host": "'"${REDIS_HOST}"'",
  50. "port": 6379,
  51. "db": 2,
  52. "expire": 2592000
  53. }
  54. ' >> config.js
  55. fi
  56. echo '}' >> config.js
  57. chown "$UID:$GID" -R /hastebin
  58. su-exec "$UID:$GID" npm start