entrypoint.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 -i -E \
  5. -e "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" \
  6. -e "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" \
  7. -e "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \;
  8. if [ -n "$LISTEN" ]; then
  9. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "\\#^Listen#s#^.*#Listen $LISTEN#" {} \;
  10. fi
  11. if [ -n "$TRUSTED_PROXY" ]; then
  12. if [ "$TRUSTED_PROXY" = "0" ]; then
  13. # Disable RemoteIPHeader and RemoteIPInternalProxy
  14. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "/^\s*RemoteIP.*$/s/^/#/" {} \;
  15. else
  16. # Custom list for RemoteIPInternalProxy
  17. find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "\\#^\s*RemoteIPInternalProxy#s#^.*#\tRemoteIPInternalProxy $TRUSTED_PROXY#" {} \;
  18. fi
  19. fi
  20. if [ -n "$OIDC_ENABLED" ] && [ "$OIDC_ENABLED" -ne 0 ]; then
  21. # Default values
  22. export OIDC_SESSION_INACTIVITY_TIMEOUT="${OIDC_SESSION_INACTIVITY_TIMEOUT:-300}"
  23. export OIDC_SESSION_MAX_DURATION="${OIDC_SESSION_MAX_DURATION:-27200}"
  24. export OIDC_SESSION_TYPE="${OIDC_SESSION_TYPE:-server-cache}"
  25. # Debian
  26. (which a2enmod >/dev/null && a2enmod -q auth_openidc) ||
  27. # Alpine
  28. (mv /etc/apache2/conf.d/mod-auth-openidc.conf.bak /etc/apache2/conf.d/mod-auth-openidc.conf && echo 'Enabling module auth_openidc.')
  29. if [ -n "$OIDC_SCOPES" ]; then
  30. # Compatibility with : as separator instead of space
  31. OIDC_SCOPES=$(echo "$OIDC_SCOPES" | tr ':' ' ')
  32. export OIDC_SCOPES
  33. fi
  34. fi
  35. if [ -n "$CRON_MIN" ]; then
  36. 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
  37. sed </etc/crontab.freshrss.default \
  38. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  39. fi
  40. ./cli/access-permissions.sh --only-userdirs
  41. php -f ./cli/prepare.php >/dev/null
  42. if [ -n "$FRESHRSS_INSTALL" ]; then
  43. # shellcheck disable=SC2046
  44. php -f ./cli/do-install.php -- \
  45. $(eval "echo \"$FRESHRSS_INSTALL\"" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  46. EXITCODE=$?
  47. if [ $EXITCODE -eq 3 ]; then
  48. echo 'ℹ️ FreshRSS already installed; no change performed.'
  49. elif [ $EXITCODE -eq 0 ]; then
  50. echo '✅ FreshRSS successfully installed.'
  51. else
  52. echo '❌ FreshRSS error during installation!'
  53. exit $EXITCODE
  54. fi
  55. fi
  56. if [ -n "$FRESHRSS_USER" ]; then
  57. # shellcheck disable=SC2046
  58. php -f ./cli/create-user.php -- \
  59. $(eval "echo \"$FRESHRSS_USER\"" | sed -r 's/[\r\n]+/\n/g' | paste -s -)
  60. EXITCODE=$?
  61. if [ $EXITCODE -eq 3 ]; then
  62. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  63. elif [ $EXITCODE -eq 0 ]; then
  64. echo '✅ FreshRSS user successfully created.'
  65. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  66. else
  67. echo '❌ FreshRSS error during the creation of a user!'
  68. exit $EXITCODE
  69. fi
  70. fi
  71. # Fix permissions of data added by prepare.php as well as a potential
  72. # installation/user setup
  73. ./cli/access-permissions.sh --only-userdirs
  74. exec "$@"