From 54b589b46d915e6e4a7596357bffa2af9f3c4aa5 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 10 Jun 2023 23:44:56 +0200 Subject: [PATCH] fix: use api url for healthcheck if enabled --- overlay/etc/templates/config.php.tmpl | 16 ++++++++-------- overlay/usr/local/bin/entrypoint | 1 + overlay/usr/local/bin/healthcheck | 11 ++++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/overlay/etc/templates/config.php.tmpl b/overlay/etc/templates/config.php.tmpl index 80c7b9b..9794f59 100644 --- a/overlay/etc/templates/config.php.tmpl +++ b/overlay/etc/templates/config.php.tmpl @@ -8,15 +8,15 @@ return array( 'title' => '{{ getenv "FRESHRSS_TITLE" "FreshRSS" }}', 'meta_description' => '{{ getenv "FRESHRSS_META_DESCRIPTION" }}', 'default_user' => '{{ getenv "FRESHRSS_DEFAULT_USER" "admin" }}', - 'allow_anonymous' => {{ getenv "FRESHRSS_ALLOW_ANONYMOUS" "false" }}, - 'allow_anonymous_refresh' => {{ getenv "FRESHRSS_ALLOW_ANONYMOUS_REFRESH" "false" }}, + 'allow_anonymous' => {{ getenv "FRESHRSS_ALLOW_ANONYMOUS" "false" | conv.ToBool }}, + 'allow_anonymous_refresh' => {{ getenv "FRESHRSS_ALLOW_ANONYMOUS_REFRESH" "false" | conv.ToBool }}, 'auth_type' => '{{ getenv "FRESHRSS_AUTH_TYPE" "form" }}', - 'api_enabled' => {{ getenv "FRESHRSS_API_ENABLED" "false" }}, - 'unsafe_autologin_enabled' => {{ getenv "FRESHRSS_UNSAFE_AUTOLOGIN_ENABLED" "false" }}, - 'simplepie_syslog_enabled' => {{ getenv "FRESHRSS_SIMPLEPIE_SYSLOG_ENABLED" "true" }}, - 'pubsubhubbub_enabled' => {{ getenv "FRESHRSS_PUBSUBHUBBUB_ENABLED" "false" }}, - 'allow_robots' => {{ getenv "FRESHRSS_ALLOW_ROBOTS" "false" }}, - 'allow_referrer' => {{ getenv "FRESHRSS_ALLOW_REFERRER" "false" }}, + 'api_enabled' => {{ getenv "FRESHRSS_API_ENABLED" "false" | conv.ToBool }}, + 'unsafe_autologin_enabled' => {{ getenv "FRESHRSS_UNSAFE_AUTOLOGIN_ENABLED" "false" | conv.ToBool }}, + 'simplepie_syslog_enabled' => {{ getenv "FRESHRSS_SIMPLEPIE_SYSLOG_ENABLED" "true" | conv.ToBool }}, + 'pubsubhubbub_enabled' => {{ getenv "FRESHRSS_PUBSUBHUBBUB_ENABLED" "false" | conv.ToBool }}, + 'allow_robots' => {{ getenv "FRESHRSS_ALLOW_ROBOTS" "false" | conv.ToBool }}, + 'allow_referrer' => {{ getenv "FRESHRSS_ALLOW_REFERRER" "false" | conv.ToBool }}, 'limits' => array( 'cookie_duration' => {{ getenv "FRESHRSS_LIMITS_COOKIE_DURATION" "2592000" }}, diff --git a/overlay/usr/local/bin/entrypoint b/overlay/usr/local/bin/entrypoint index 6b34d4e..cd9740b 100755 --- a/overlay/usr/local/bin/entrypoint +++ b/overlay/usr/local/bin/entrypoint @@ -47,6 +47,7 @@ if [ $EXITCODE -eq 3 ]; then elif [ $EXITCODE -eq 0 ]; then log_info "FreshRSS user successfully created" ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user "${FRESHRSS_DEFAULT_USER:-admin}" + ./cli/access-permissions.sh else log_error "FreshRSS error during the creation of a user: ${ERROR}" exit $EXITCODE diff --git a/overlay/usr/local/bin/healthcheck b/overlay/usr/local/bin/healthcheck index 7a990c7..3cd2643 100755 --- a/overlay/usr/local/bin/healthcheck +++ b/overlay/usr/local/bin/healthcheck @@ -1,3 +1,12 @@ #!/usr/bin/env sh -(php -r "readfile('http://127.0.0.1:8080/i/');" | grep -q 'jsonVars') || exit 1 +# shellcheck disable=SC3040 +set -eo pipefail + +if [ "$(gomplate -i '{{ getenv "FRESHRSS_API_ENABLED" "false" | conv.ToBool }}')" = "true" ]; then + (php -r "readfile('http://127.0.0.1:8080/api/fever.php');" | grep -q 'api_versionX') || exit 1 +else + (php -r "readfile('http://127.0.0.1:8080/i/');" | grep -q 'jsonVars') || exit 1 +fi + +exit 0