entrypoint.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. sed </var/www/FreshRSS/Docker/crontab.default \
  19. -r "s#^[^ ]+ #$CRON_MIN #" | crontab -
  20. fi
  21. if [ -n "$FRESHRSS_INSTALL" ]; then
  22. # shellcheck disable=SC2046
  23. php -f ./cli/do-install.php -- \
  24. $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
  25. 1>/tmp/out.txt 2>/tmp/err.txt
  26. EXITCODE=$?
  27. grep -v 'Remember to' /tmp/out.txt
  28. grep -v 'Please use' /tmp/err.txt 1>&2
  29. if [ $EXITCODE -eq 3 ]; then
  30. echo 'ℹ️ FreshRSS already installed; no change performed.'
  31. elif [ $EXITCODE -eq 0 ]; then
  32. echo '✅ FreshRSS successfully installed.'
  33. else
  34. rm -f /tmp/out.txt /tmp/err.txt
  35. echo '❌ FreshRSS error during installation!'
  36. exit $EXITCODE
  37. fi
  38. rm -f /tmp/out.txt /tmp/err.txt
  39. fi
  40. if [ -n "$FRESHRSS_USER" ]; then
  41. # shellcheck disable=SC2046
  42. php -f ./cli/create-user.php -- \
  43. $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
  44. 1>/tmp/out.txt 2>/tmp/err.txt
  45. EXITCODE=$?
  46. grep -v 'Remember to' /tmp/out.txt
  47. cat /tmp/err.txt 1>&2
  48. if [ $EXITCODE -eq 3 ]; then
  49. echo 'ℹ️ FreshRSS user already exists; no change performed.'
  50. elif [ $EXITCODE -eq 0 ]; then
  51. echo '✅ FreshRSS user successfully created.'
  52. ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
  53. else
  54. rm -f /tmp/out.txt /tmp/err.txt
  55. echo '❌ FreshRSS error during the creation of a user!'
  56. exit $EXITCODE
  57. fi
  58. rm -f /tmp/out.txt /tmp/err.txt
  59. fi
  60. chown -R :www-data .
  61. chmod -R g+r . && chmod -R g+w ./data/
  62. exec "$@"