mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-12 16:12:29 +02:00
Fix cron jobs not running in Firefly III Data Importer addon
- Change cronupdate shebang from bashio to /bin/bash (cron PATH lacks bashio) - Remove bashio API calls from cron script (no Supervisor access in cron) - Source /.env in cron script to load all env_vars from 00-global_var.sh - Persist SILENT_MODE to /etc/environment for cron access - Remove destructive `sed 's|root|www-data|g'` on /etc/crontab - Fix /etc/environment permissions from 600 to 644 for cron readability
This commit is contained in:
committed by
GitHub
parent
b947226ac9
commit
e22b44b5ec
@@ -27,6 +27,10 @@ export CAN_POST_FILES="$(bashio::config "CAN_POST_FILES")"
|
|||||||
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
|
# Persist variables to /etc/environment for cron jobs
|
||||||
|
SILENT_MODE="false"
|
||||||
|
if bashio::config.true 'silent'; then
|
||||||
|
SILENT_MODE="true"
|
||||||
|
fi
|
||||||
{
|
{
|
||||||
[ -n "$JSON_CONFIGURATION_DIR" ] && echo "JSON_CONFIGURATION_DIR=\"$JSON_CONFIGURATION_DIR\""
|
[ -n "$JSON_CONFIGURATION_DIR" ] && echo "JSON_CONFIGURATION_DIR=\"$JSON_CONFIGURATION_DIR\""
|
||||||
echo "CONFIG_LOCATION=\"$CONFIGSOURCE\""
|
echo "CONFIG_LOCATION=\"$CONFIGSOURCE\""
|
||||||
@@ -35,8 +39,9 @@ export CAN_POST_AUTOIMPORT="$(bashio::config "CAN_POST_AUTOIMPORT")"
|
|||||||
echo "AUTO_IMPORT_SECRET=\"$AUTO_IMPORT_SECRET\""
|
echo "AUTO_IMPORT_SECRET=\"$AUTO_IMPORT_SECRET\""
|
||||||
echo "CAN_POST_FILES=\"$CAN_POST_FILES\""
|
echo "CAN_POST_FILES=\"$CAN_POST_FILES\""
|
||||||
echo "CAN_POST_AUTOIMPORT=\"$CAN_POST_AUTOIMPORT\""
|
echo "CAN_POST_AUTOIMPORT=\"$CAN_POST_AUTOIMPORT\""
|
||||||
|
echo "SILENT_MODE=\"$SILENT_MODE\""
|
||||||
} >> /etc/environment
|
} >> /etc/environment
|
||||||
chmod 600 /etc/environment
|
chmod 644 /etc/environment
|
||||||
|
|
||||||
################
|
################
|
||||||
# CRON OPTIONS #
|
# CRON OPTIONS #
|
||||||
@@ -54,9 +59,6 @@ if bashio::config.has_value 'Updates'; then
|
|||||||
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
||||||
chmod 755 /etc/cron."${FREQUENCY}"/cronupdate
|
chmod 755 /etc/cron."${FREQUENCY}"/cronupdate
|
||||||
|
|
||||||
# Sets cron to run with www-data user
|
|
||||||
sed -i 's|root|www-data|g' /etc/crontab
|
|
||||||
|
|
||||||
# Starts cron
|
# Starts cron
|
||||||
service cron start
|
service cron start
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
#!/usr/bin/env bashio
|
#!/bin/bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Source environment variables for cron context
|
# Source environment variables for cron context
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
if [ -f /etc/environment ]; then set -a; . /etc/environment; set +a; fi
|
if [ -f /etc/environment ]; then set -a; . /etc/environment; set +a; fi
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
if [ -f /.env ]; then set -a; . /.env; set +a; fi
|
||||||
|
|
||||||
# Use persisted value instead of calling bashio::config (www-data may lack API access)
|
# Use persisted value instead of calling bashio::config (www-data may lack API access)
|
||||||
CONFIGSOURCE="${CONFIG_LOCATION}"
|
CONFIGSOURCE="${CONFIG_LOCATION}"
|
||||||
|
|
||||||
(
|
(
|
||||||
bashio::log.info "Running update according to defined schedule. Files located in $CONFIGSOURCE/import_files will be imported. If /config, it is accessible in the folder /addon_configs/xxx-firefly_data_importer when using the Filebrowser addon"
|
echo "[INFO] Running update according to defined schedule. Files located in $CONFIGSOURCE/import_files will be imported."
|
||||||
if bashio::config.true 'silent'; then
|
if [ "${SILENT_MODE}" = "true" ]; then
|
||||||
bashio::log.warning "Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug"
|
echo "[WARNING] Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug"
|
||||||
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$CONFIGSOURCE/import_files" >/dev/null
|
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$CONFIGSOURCE/import_files" >/dev/null
|
||||||
else
|
else
|
||||||
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$CONFIGSOURCE/import_files"
|
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$CONFIGSOURCE/import_files"
|
||||||
|
|||||||
Reference in New Issue
Block a user