entrypoint.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. find /etc/apache2/*/ -type f -name '*openidc.conf' -exec sed -r -i "/^#?OIDCSessionInactivityTimeout/s/^.*/OIDCSessionInactivityTimeout ${OIDCSessionInactivityTimeout:-86400}/" {} \;
  30. find /etc/apache2/*/ -type f -name '*openidc.conf' -exec sed -r -i "/^#?OIDCSessionMaxDuration/s/^.*/OIDCSessionMaxDuration ${OIDCSessionMaxDuration:-2592000}/" {} \;
  31. fi
  32. if [ -n "$CRON_MIN" ]; then
  33. awk -v RS='\0' '!/^(FRESHRSS_INSTALL|FRESHRSS_USER|HOME|PATH|PWD|SHLVL|TERM|_)=/ {gsub("\047", "\047\\\047\047"); print "export \047" $0 "\047"}' /proc/self/environ >/var/www/FreshRSS/Docker/env.txt
  34. sed </etc/crontab.freshrss.default \
  35. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  36. fi
  37. ./cli/access-permissions.sh
  38. php -f ./cli/prepare.php >/dev/null
  39. if [ -n "$FRESHRSS_INSTALL" ]; then
  40. # shellcheck disable=SC2046
  41. php -f ./cli/do-install.php -- \
  42. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  43. EXITCODE=$?
  44. if [ $EXITCODE -eq 3 ]; then
  45. echo 'ℹ️ FreshRSS already installed; no change performed.'
  46. elif [ $EXITCODE -eq 0 ]; then
  47. echo '✅ FreshRSS successfully installed.'
  48. else
  49. echo '❌ FreshRSS error during installation!'
  50. exit $EXITCODE
  51. fi
  52. fi
  53. if [ -n "$FRESHRSS_USER" ]; then
  54. # shellcheck disable=SC2046
  55. php -f ./cli/create-user.php -- \
  56. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  57. EXITCODE=$?
  58. if [ $EXITCODE -eq 3 ]; then
  59. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  60. elif [ $EXITCODE -eq 0 ]; then
  61. echo '✅ FreshRSS user successfully created.'
  62. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  63. else
  64. echo '❌ FreshRSS error during the creation of a user!'
  65. exit $EXITCODE
  66. fi
  67. fi
  68. ./cli/access-permissions.sh
  69. exec "$@"