mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-08 08:35:57 +02:00
Fix cron auto-import env vars and health check log spam for Firefly III Data Importer
- Source /etc/environment in cronupdate to load addon env vars (FIREFLY_III_URL, etc.) - Persist cron-needed vars (JSON_CONFIGURATION_DIR, IMPORT_DIR_WHITELIST, etc.) to /etc/environment - Fix inverted nginx map values that caused health check logs to spam while suppressing real requests Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
@@ -168,7 +168,7 @@ RUN \
|
|||||||
\
|
\
|
||||||
# Handle Nginx configuration
|
# Handle Nginx configuration
|
||||||
if [ -f /etc/nginx/nginx.conf ]; then \
|
if [ -f /etc/nginx/nginx.conf ]; then \
|
||||||
awk '/http \{/{print; print "map $http_user_agent $dontlog {\n default 0;\n \"~*HealthCheck\" 1;\n}\naccess_log /var/log/nginx/access.log combined if=$dontlog;"; next}1' /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.new && \
|
awk '/http \{/{print; print "map $http_user_agent $loggable {\n default 1;\n \"~*HealthCheck\" 0;\n}\naccess_log /var/log/nginx/access.log combined if=$loggable;"; next}1' /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.new && \
|
||||||
mv /etc/nginx/nginx.conf.new /etc/nginx/nginx.conf; \
|
mv /etc/nginx/nginx.conf.new /etc/nginx/nginx.conf; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ export CAN_POST_FILES="$(bashio::config "CAN_POST_FILES")"
|
|||||||
# shellcheck disable=SC2155
|
# shellcheck disable=SC2155
|
||||||
export CAN_POST_AUTOIMPORT="$(bashio::config "CAN_POST_AUTOIMPORT")"
|
export CAN_POST_AUTOIMPORT="$(bashio::config "CAN_POST_AUTOIMPORT")"
|
||||||
|
|
||||||
|
# Persist variables to /etc/environment for cron jobs
|
||||||
|
{
|
||||||
|
[ -n "$JSON_CONFIGURATION_DIR" ] && echo "JSON_CONFIGURATION_DIR=\"$JSON_CONFIGURATION_DIR\""
|
||||||
|
echo "IMPORT_DIR_ALLOWLIST=\"$IMPORT_DIR_ALLOWLIST\""
|
||||||
|
echo "IMPORT_DIR_WHITELIST=\"$IMPORT_DIR_WHITELIST\""
|
||||||
|
echo "AUTO_IMPORT_SECRET=\"$AUTO_IMPORT_SECRET\""
|
||||||
|
echo "CAN_POST_FILES=\"$CAN_POST_FILES\""
|
||||||
|
echo "CAN_POST_AUTOIMPORT=\"$CAN_POST_AUTOIMPORT\""
|
||||||
|
} >> /etc/environment
|
||||||
|
chmod 600 /etc/environment
|
||||||
|
|
||||||
################
|
################
|
||||||
# CRON OPTIONS #
|
# CRON OPTIONS #
|
||||||
################
|
################
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Source environment variables for cron context
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
if [ -f /etc/environment ]; then set -a; . /etc/environment; set +a; fi
|
||||||
|
|
||||||
CONFIGSOURCE="$(bashio::config "CONFIG_LOCATION")"
|
CONFIGSOURCE="$(bashio::config "CONFIG_LOCATION")"
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user