entrypoint.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. (
  32. echo "export TZ=$TZ"
  33. echo "export COPY_LOG_TO_SYSLOG=$COPY_LOG_TO_SYSLOG"
  34. echo "export COPY_SYSLOG_TO_STDERR=$COPY_SYSLOG_TO_STDERR"
  35. echo "export FRESHRSS_ENV=$FRESHRSS_ENV"
  36. echo "export DATA_PATH=$DATA_PATH"
  37. ) >/var/www/FreshRSS/Docker/env.txt
  38. sed </etc/crontab.freshrss.default \
  39. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  40. fi
  41. ./cli/access-permissions.sh
  42. php -f ./cli/prepare.php >/dev/null
  43. if [ -n "$FRESHRSS_INSTALL" ]; then
  44. # shellcheck disable=SC2046
  45. php -f ./cli/do-install.php -- \
  46. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  47. EXITCODE=$?
  48. if [ $EXITCODE -eq 3 ]; then
  49. echo 'ℹ️ FreshRSS already installed; no change performed.'
  50. elif [ $EXITCODE -eq 0 ]; then
  51. echo '✅ FreshRSS successfully installed.'
  52. else
  53. echo '❌ FreshRSS error during installation!'
  54. exit $EXITCODE
  55. fi
  56. fi
  57. if [ -n "$FRESHRSS_USER" ]; then
  58. # shellcheck disable=SC2046
  59. php -f ./cli/create-user.php -- \
  60. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  61. EXITCODE=$?
  62. if [ $EXITCODE -eq 3 ]; then
  63. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  64. elif [ $EXITCODE -eq 0 ]; then
  65. echo '✅ FreshRSS user successfully created.'
  66. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  67. else
  68. echo '❌ FreshRSS error during the creation of a user!'
  69. exit $EXITCODE
  70. fi
  71. fi
  72. ./cli/access-permissions.sh
  73. exec "$@"