entrypoint.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime
  3. echo "$TZ" >/etc/timezone
  4. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \;
  5. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" {} \;
  6. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \;
  7. if [ -n "$LISTEN" ]; then
  8. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "\\#^Listen#s#^.*#Listen $LISTEN#" {} \;
  9. fi
  10. if [ -n "$TRUSTED_PROXY" ]; then
  11. if [ "$TRUSTED_PROXY" = "0" ]; then
  12. # Disable RemoteIPHeader and RemoteIPInternalProxy
  13. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "/^\s*RemoteIP.*$/s/^/#/" {} \;
  14. else
  15. # Custom list for RemoteIPInternalProxy
  16. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "\\#^\s*RemoteIPInternalProxy#s#^.*#\tRemoteIPInternalProxy $TRUSTED_PROXY#" {} \;
  17. fi
  18. fi
  19. if [ -n "$OIDC_ENABLED" ] && [ "$OIDC_ENABLED" -ne 0 ]; then
  20. # Debian
  21. (which a2enmod >/dev/null && a2enmod -q auth_openidc) ||
  22. # Alpine
  23. (mv /etc/apache2/conf.d/mod-auth-openidc.conf.bak /etc/apache2/conf.d/mod-auth-openidc.conf && echo 'Enabling module auth_openidc.')
  24. if [ -n "$OIDC_SCOPES" ]; then
  25. # Compatibility with : as separator instead of space
  26. OIDC_SCOPES=$(echo "$OIDC_SCOPES" | tr ':' ' ')
  27. export OIDC_SCOPES
  28. fi
  29. fi
  30. if [ -n "$CRON_MIN" ]; then
  31. # shellcheck disable=SC2002
  32. cat /proc/self/environ | tr '\0' '\n' | grep -vE '^(HOME|PATH|PWD|SHLVL|TERM|_)=' | sort -u | sed 's/^/export /' >/var/www/FreshRSS/Docker/env.txt
  33. sed </etc/crontab.freshrss.default \
  34. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  35. fi
  36. ./cli/access-permissions.sh
  37. php -f ./cli/prepare.php >/dev/null
  38. if [ -n "$FRESHRSS_INSTALL" ]; then
  39. # shellcheck disable=SC2046
  40. php -f ./cli/do-install.php -- \
  41. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  42. EXITCODE=$?
  43. if [ $EXITCODE -eq 3 ]; then
  44. echo 'ℹ️ FreshRSS already installed; no change performed.'
  45. elif [ $EXITCODE -eq 0 ]; then
  46. echo '✅ FreshRSS successfully installed.'
  47. else
  48. echo '❌ FreshRSS error during installation!'
  49. exit $EXITCODE
  50. fi
  51. fi
  52. if [ -n "$FRESHRSS_USER" ]; then
  53. # shellcheck disable=SC2046
  54. php -f ./cli/create-user.php -- \
  55. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  56. EXITCODE=$?
  57. if [ $EXITCODE -eq 3 ]; then
  58. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  59. elif [ $EXITCODE -eq 0 ]; then
  60. echo '✅ FreshRSS user successfully created.'
  61. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  62. else
  63. echo '❌ FreshRSS error during the creation of a user!'
  64. exit $EXITCODE
  65. fi
  66. fi
  67. ./cli/access-permissions.sh
  68. exec "$@"