entrypoint.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # Default values
  21. export OIDC_SESSION_INACTIVITY_TIMEOUT="${OIDC_SESSION_INACTIVITY_TIMEOUT:-300}"
  22. export OIDC_SESSION_MAX_DURATION="${OIDC_SESSION_MAX_DURATION:-27200}"
  23. export OIDC_SESSION_TYPE="${OIDC_SESSION_TYPE:-server-cache}"
  24. # Debian
  25. (which a2enmod >/dev/null && a2enmod -q auth_openidc) ||
  26. # Alpine
  27. (mv /etc/apache2/conf.d/mod-auth-openidc.conf.bak /etc/apache2/conf.d/mod-auth-openidc.conf && echo 'Enabling module auth_openidc.')
  28. if [ -n "$OIDC_SCOPES" ]; then
  29. # Compatibility with : as separator instead of space
  30. OIDC_SCOPES=$(echo "$OIDC_SCOPES" | tr ':' ' ')
  31. export OIDC_SCOPES
  32. fi
  33. fi
  34. if [ -n "$CRON_MIN" ]; then
  35. 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
  36. sed </etc/crontab.freshrss.default \
  37. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  38. fi
  39. ./cli/access-permissions.sh
  40. php -f ./cli/prepare.php >/dev/null
  41. if [ -n "$FRESHRSS_INSTALL" ]; then
  42. # shellcheck disable=SC2046
  43. php -f ./cli/do-install.php -- \
  44. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  45. EXITCODE=$?
  46. if [ $EXITCODE -eq 3 ]; then
  47. echo 'ℹ️ FreshRSS already installed; no change performed.'
  48. elif [ $EXITCODE -eq 0 ]; then
  49. echo '✅ FreshRSS successfully installed.'
  50. else
  51. echo '❌ FreshRSS error during installation!'
  52. exit $EXITCODE
  53. fi
  54. fi
  55. if [ -n "$FRESHRSS_USER" ]; then
  56. # shellcheck disable=SC2046
  57. php -f ./cli/create-user.php -- \
  58. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  59. EXITCODE=$?
  60. if [ $EXITCODE -eq 3 ]; then
  61. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  62. elif [ $EXITCODE -eq 0 ]; then
  63. echo '✅ FreshRSS user successfully created.'
  64. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  65. else
  66. echo '❌ FreshRSS error during the creation of a user!'
  67. exit $EXITCODE
  68. fi
  69. fi
  70. ./cli/access-permissions.sh
  71. exec "$@"