mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-01 05:14:04 +02:00
add auto options
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
|
- Add auto import of csv files periodically (see readme)
|
||||||
|
- Add auto import of configurations (see readme)
|
||||||
- Add config.yaml configurable options (see readme)
|
- Add config.yaml configurable options (see readme)
|
||||||
|
|
||||||
## version-0.7.0 (22-01-2022)
|
## version-0.7.0 (22-01-2022)
|
||||||
|
|
||||||
- Update to latest version from fireflyiii/data-importer
|
- Update to latest version from fireflyiii/data-importer
|
||||||
|
|
||||||
## version-0.6.5 (21-01-2022)
|
## version-0.6.5 (21-01-2022)
|
||||||
|
|
||||||
- Update to latest version from fireflyiii/data-importer
|
- Update to latest version from fireflyiii/data-importer
|
||||||
|
|
||||||
## 0.7.0 (21-01-2022)
|
## 0.7.0 (21-01-2022)
|
||||||
|
|
||||||
- Update to latest version from firefly-iii/data-importer
|
- Update to latest version from firefly-iii/data-importer
|
||||||
|
|
||||||
## 0.6.5 (15-01-2022)
|
## 0.6.5 (15-01-2022)
|
||||||
|
|
||||||
- Update to latest version from firefly-iii/data-importer
|
- Update to latest version from firefly-iii/data-importer
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get
|
|||||||
&& chmod -R 755 /etc/cont-init.d || printf '%s\n' "${MODULES}" >/MODULESFILE
|
&& chmod -R 755 /etc/cont-init.d || printf '%s\n' "${MODULES}" >/MODULESFILE
|
||||||
|
|
||||||
# Manual apps
|
# Manual apps
|
||||||
ENV PACKAGES=""
|
ENV PACKAGES="cron"
|
||||||
|
|
||||||
# Automatic apps & bashio
|
# Automatic apps & bashio
|
||||||
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ This addon is based on the docker image https://hub.docker.com/r/fireflyiii/data
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Read official documentation for information how to set the variables: https://docs.firefly-iii.org/data-importer
|
Read official documentation for information how to set the variables: https://docs.firefly-iii.org/data-importer.
|
||||||
|
Configurations can be added in the /config/addons_config/fireflyiii_data_importer/configurations folder according to :https://docs.firefly-iii.org/data-importer/help/config/
|
||||||
|
An auto import can be made by adding files in /config/addons_config/fireflyiii_data_importer/import_files according to : https://docs.firefly-iii.org/data-importer/usage/command_line/
|
||||||
|
|
||||||
Options can be configured through two ways :
|
Options can be configured through two ways :
|
||||||
|
|
||||||
@@ -35,6 +37,8 @@ Options can be configured through two ways :
|
|||||||
"NORDIGEN_KEY": your Nordigen Client Secret
|
"NORDIGEN_KEY": your Nordigen Client Secret
|
||||||
"SPECTRE_APP_ID": your Spectre / Salt Edge Client ID
|
"SPECTRE_APP_ID": your Spectre / Salt Edge Client ID
|
||||||
"SPECTRE_SECRET": your Spectre / Salt Edge Client secret
|
"SPECTRE_SECRET": your Spectre / Salt Edge Client secret
|
||||||
|
"Updates": hourly|daily|weekly # Sets an automatic upload of files set in /config/addons_config/fireflyiii_data_importer/import_files
|
||||||
|
"silent": true # suppresses debug messages
|
||||||
```
|
```
|
||||||
|
|
||||||
- Config.yaml
|
- Config.yaml
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
{
|
{
|
||||||
"apparmor": true,
|
"apparmor": true,
|
||||||
"arch": [
|
"arch": ["aarch64", "amd64", "armv7"],
|
||||||
"aarch64",
|
|
||||||
"amd64",
|
|
||||||
"armv7"
|
|
||||||
],
|
|
||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
"description": "Data importer for Firefly III (separate addon)",
|
"description": "Data importer for Firefly III (separate addon)",
|
||||||
"devices": [],
|
"devices": [],
|
||||||
"environment": {
|
"environment": {
|
||||||
"TRUSTED_PROXIES": "**"
|
"TRUSTED_PROXIES": "**"
|
||||||
},
|
},
|
||||||
"map": [
|
"map": ["config:rw", "share:rw", "ssl"],
|
||||||
"config:rw",
|
|
||||||
"share:rw",
|
|
||||||
"ssl"
|
|
||||||
],
|
|
||||||
"name": "Firefly iii Data Importer",
|
"name": "Firefly iii Data Importer",
|
||||||
"options": {
|
"options": {
|
||||||
"CONFIG_LOCATION": "/config/addons_config/fireflyiii_data_importer/config.yaml"
|
"CONFIG_LOCATION": "/config/addons_config/fireflyiii_data_importer/config.yaml"
|
||||||
@@ -34,11 +26,13 @@
|
|||||||
"NORDIGEN_KEY": "str?",
|
"NORDIGEN_KEY": "str?",
|
||||||
"SPECTRE_APP_ID": "str?",
|
"SPECTRE_APP_ID": "str?",
|
||||||
"SPECTRE_SECRET": "str?",
|
"SPECTRE_SECRET": "str?",
|
||||||
"CONFIG_LOCATION": "str"
|
"CONFIG_LOCATION": "str",
|
||||||
|
"Updates": "list(|hourly|daily|weekly)?",
|
||||||
|
"silent": "bool?"
|
||||||
},
|
},
|
||||||
"slug": "fireflyiii_data_importer",
|
"slug": "fireflyiii_data_importer",
|
||||||
"upstream": "version-0.7.0",
|
"upstream": "version-0.7.0",
|
||||||
"url": "https://github.com/alexbelgium/hassio-addons",
|
"url": "https://github.com/alexbelgium/hassio-addons",
|
||||||
"version": "version-0.7.0-2",
|
"version": "version-0.7.0-3",
|
||||||
"webui": "[PROTO:ssl]://[HOST]:[PORT:8080]"
|
"webui": "[PROTO:ssl]://[HOST]:[PORT:8080]"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
|||||||
|
|
||||||
# Create directory
|
# Create directory
|
||||||
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
||||||
|
mkdir -p "$(dirname "${CONFIGSOURCE}/import_files")"
|
||||||
|
mkdir -p "$(dirname "${CONFIGSOURCE}/configurations")"
|
||||||
|
|
||||||
# Make sure permissions are right
|
# Make sure permissions are right
|
||||||
chown -R $(id -u):$(id -g) "$(dirname "${CONFIGSOURCE}")"
|
chown -R $(id -u):$(id -g) "$(dirname "${CONFIGSOURCE}")"
|
||||||
|
|||||||
@@ -1,5 +1,109 @@
|
|||||||
#!/usr/bin/env bashio
|
#!/usr/bin/env bashio
|
||||||
|
|
||||||
|
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||||
|
|
||||||
|
#################
|
||||||
|
# CONFIG IMPORT #
|
||||||
|
#################
|
||||||
|
|
||||||
|
if [ "$(ls -A $CONFIGSOURCE/configurations)" ]; then
|
||||||
|
bashio::log.info "Configurations were found in $CONFIGSOURCE/configurations, they will be loaded."
|
||||||
|
JSON_CONFIGURATION_DIR="$CONFIGSOURCE/configurations"
|
||||||
|
export JSON_CONFIGURATION_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# CRON OPTIONS #
|
||||||
|
################
|
||||||
|
|
||||||
|
if bashio::config.has_value 'Updates'; then
|
||||||
|
|
||||||
|
CONFIGSOURCE="$(dirname "${CONFIGSOURCE}/import_files")"
|
||||||
|
|
||||||
|
if [ "$(ls -A $CONFIGSOURCE)" ]; then
|
||||||
|
# Align update with options
|
||||||
|
echo ""
|
||||||
|
FREQUENCY=$(bashio::config 'Updates')
|
||||||
|
bashio::log.info "$FREQUENCY updates"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Sets cron // do not delete this message
|
||||||
|
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
||||||
|
chmod 777 /etc/cron."${FREQUENCY}"/cronupdate
|
||||||
|
|
||||||
|
# Sets cron to run with www-data user
|
||||||
|
sed -i 's|root|www-data|g' /etc/crontab
|
||||||
|
|
||||||
|
# Starts cron
|
||||||
|
service cron start
|
||||||
|
|
||||||
|
# Export variables
|
||||||
|
IMPORT_DIR_WHITELIST="$CONFIGSOURCE"
|
||||||
|
export IMPORT_DIR_WHITELIST
|
||||||
|
|
||||||
|
bashio::log.info "Automatic updates were requested. The files in $CONFIGSOURCE will be imported $FREQUENCY."
|
||||||
|
|
||||||
|
else
|
||||||
|
bashio::log.fatal "Automatic updates were requested, but there are no configuration files in $CONFIGSOURCE. There will therefore be be no automatic updates."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
bashio::log.info "Automatic updates not set in addon config. If you add configuration files in $CONFIGSOURCE, they won't be automatically updated."
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
##############
|
||||||
|
# LAUNCH APP #
|
||||||
|
##############
|
||||||
|
|
||||||
|
bashio::log.info "Please wait while the app is loading !"
|
||||||
|
|
||||||
|
/./usr/local/bin/entrypoint.sh
|
||||||
|
export JSON_CONFIGURATION_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# CRON OPTIONS #
|
||||||
|
################
|
||||||
|
|
||||||
|
if bashio::config.has_value 'Updates'; then
|
||||||
|
|
||||||
|
CONFIGSOURCE="$(dirname "${CONFIGSOURCE}/import_files")"
|
||||||
|
|
||||||
|
if [ "$(ls -A $CONFIGSOURCE)" ]; then
|
||||||
|
# Align update with options
|
||||||
|
echo ""
|
||||||
|
FREQUENCY=$(bashio::config 'Updates')
|
||||||
|
bashio::log.info "$FREQUENCY updates"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Sets cron // do not delete this message
|
||||||
|
cp /templates/cronupdate /etc/cron."${FREQUENCY}"/
|
||||||
|
chmod 777 /etc/cron."${FREQUENCY}"/cronupdate
|
||||||
|
|
||||||
|
# Sets cron to run with www-data user
|
||||||
|
sed -i 's|root|www-data|g' /etc/crontab
|
||||||
|
|
||||||
|
# Starts cron
|
||||||
|
service cron start
|
||||||
|
|
||||||
|
# Export variables
|
||||||
|
IMPORT_DIR_WHITELIST="$CONFIGSOURCE"
|
||||||
|
export IMPORT_DIR_WHITELIST
|
||||||
|
|
||||||
|
bashio::log.info "Automatic updates were requested. The files in $CONFIGSOURCE will be imported $FREQUENCY."
|
||||||
|
|
||||||
|
else
|
||||||
|
bashio::log.fatal "Automatic updates were requested, but there are no configuration files in $CONFIGSOURCE. There will therefore be be no automatic updates."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
bashio::log.info "Automatic updates not set in addon config. If you add configuration files in $CONFIGSOURCE, they won't be automatically updated."
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# LAUNCH APP #
|
# LAUNCH APP #
|
||||||
##############
|
##############
|
||||||
|
|||||||
13
fireflyiii_data_importer/rootfs/templates/cronupdate
Normal file
13
fireflyiii_data_importer/rootfs/templates/cronupdate
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bashio
|
||||||
|
|
||||||
|
PATHTOFILES="$(bashio::config "CONFIG_LOCATION")"
|
||||||
|
PATHTOFILES="$(dirname "${PATHTOFILES}")"
|
||||||
|
|
||||||
|
bashio::log.info "Running update according to defined schedule. Files located in $PATHTOFILES will be imported"
|
||||||
|
if bashio::config.true 'silent'; then
|
||||||
|
bashio::log.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 >/dev/null
|
||||||
|
else
|
||||||
|
/usr/local/bin/php /var/www/html/artisan importer:auto-import "$PATHTOFILES"/import_files
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user