entrypoint.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. php -f ./cli/prepare.php >/dev/null
  3. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \;
  4. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" {} \;
  5. find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \;
  6. # Disable built-in updates when using Docker, as the full image is supposed to be updated instead.
  7. sed -r -i "\\#disable_update#s#^.*#\t'disable_update' => true,#" ./config.default.php
  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 "$CRON_MIN" ]; then
  12. (
  13. echo "export TZ=$TZ"
  14. echo "export COPY_LOG_TO_SYSLOG=$COPY_LOG_TO_SYSLOG"
  15. echo "export COPY_SYSLOG_TO_STDERR=$COPY_SYSLOG_TO_STDERR"
  16. echo "export FRESHRSS_ENV=$FRESHRSS_ENV"
  17. ) >/var/www/FreshRSS/Docker/env.txt
  18. crontab -l | sed -r "\\#FreshRSS#s#^[^ ]+ #$CRON_MIN #" | crontab -
  19. fi
  20. if [ -n "$FRESHRSS_INSTALL" ]; then
  21. # shellcheck disable=SC2046
  22. php -f ./cli/do-install.php -- \
  23. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
  24. 1>/tmp/out.txt 2>/tmp/err.txt
  25. EXITCODE=$?
  26. grep -v 'Remember to' /tmp/out.txt
  27. grep -v 'Please use' /tmp/err.txt 1>&2
  28. if [ $EXITCODE -eq 3 ]; then
  29. echo 'ℹ️ FreshRSS already installed; no change performed.'
  30. elif [ $EXITCODE -eq 0 ]; then
  31. echo '✅ FreshRSS successfully installed.'
  32. else
  33. rm -f /tmp/out.txt /tmp/err.txt
  34. echo '❌ FreshRSS error during installation!'
  35. exit $EXITCODE
  36. fi
  37. rm -f /tmp/out.txt /tmp/err.txt
  38. fi
  39. if [ -n "$FRESHRSS_USER" ]; then
  40. # shellcheck disable=SC2046
  41. php -f ./cli/create-user.php -- \
  42. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
  43. 1>/tmp/out.txt 2>/tmp/err.txt
  44. EXITCODE=$?
  45. grep -v 'Remember to' /tmp/out.txt
  46. cat /tmp/err.txt 1>&2
  47. if [ $EXITCODE -eq 3 ]; then
  48. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  49. elif [ $EXITCODE -eq 0 ]; then
  50. echo '✅ FreshRSS user successfully created.'
  51. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  52. else
  53. rm -f /tmp/out.txt /tmp/err.txt
  54. echo '❌ FreshRSS error during the creation of a user!'
  55. exit $EXITCODE
  56. fi
  57. rm -f /tmp/out.txt /tmp/err.txt
  58. fi
  59. chown -R :www-data .
  60. chmod -R g+r . && chmod -R g+w ./data/
  61. exec "$@"