entrypoint.sh 2.2 KB

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