diff --git a/fireflyiii/CHANGELOG.md b/fireflyiii/CHANGELOG.md index 4bd18c2a8..1d1528f0b 100644 --- a/fireflyiii/CHANGELOG.md +++ b/fireflyiii/CHANGELOG.md @@ -1,14 +1,10 @@ -- Allowed automatic update in hourly, daily or weekly setting from addon options ## 5.6.10 (09-01-2022) - - Update to latest version from firefly-iii/firefly-iii ## 5.6.9 (04-01-2022) - - Update to latest version from firefly-iii/firefly-iii ## 5.6.8 (29-12-2021) - - Update to latest version from firefly-iii/firefly-iii - Initial release diff --git a/fireflyiii/Dockerfile b/fireflyiii/Dockerfile index 4599f5b7f..6ba05707c 100644 --- a/fireflyiii/Dockerfile +++ b/fireflyiii/Dockerfile @@ -34,19 +34,8 @@ FROM ${BUILD_FROM} # Copy local files COPY rootfs/ / -# Modules -ARG MODULES="00-banner.sh 00-global_var.sh 90-config_yaml.sh" - -# Automatic modules download -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); fi && \ - if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi && \ - mkdir -p /tmpscripts /etc/cont-init.d && \ - for scripts in $MODULES; do curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/$scripts" -o /tmpscripts/"$scripts"; done && \ - if [ -d /etc/cont-init.d ]; then /bin/cp -rf /tmpscripts/* /etc/cont-init.d/ && chmod -R 755 /etc/cont-init.d; fi && \ - rm -rf /tmpscripts || printf '%s\n' "${MODULES:-}" > /MODULESFILE - # Manual apps -ENV PACKAGES="cron" +ENV PACKAGES="" # 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); fi && \ @@ -62,7 +51,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/entrypoint.sh" ] +CMD [ "/entrypoint.sh" ] ############ # 5 Labels # diff --git a/fireflyiii/Readme.md b/fireflyiii/Readme.md index 7b1ff6483..963dad6b1 100644 --- a/fireflyiii/Readme.md +++ b/fireflyiii/Readme.md @@ -4,7 +4,7 @@ [donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white -![Supports +![Supports Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports smb mounts][smb-shield] @@ -19,7 +19,7 @@ This addon is based on the docker image https://hub.docker.com/r/fireflyiii/core ## Configuration -PLEASE CHANGE YOUR APP_KEY BEFORE FIRST LAUNCH! YOU WON'T BE ABLE AFTERWRADS WITHOUT RESETTING YOUR DATABASE. +PLEASE CHANGE YOUR APP_KEY BEFORE FIRST LAUNCH! YOU WON'T BE ABLE AFTERWRADS WITHOUT RESETTING YOUR DATABASE. Options can be configured through two ways : @@ -34,7 +34,6 @@ Options can be configured through two ways : "DB_DATABASE": "CHANGEME" # only needed if using a remote database "DB_USERNAME": "CHANGEME" # only needed if using a remote database "DB_PASSWORD": "CHANGEME" # only needed if using a remote database -"Updates": hourly|daily|weekly # Sets an automatic update ``` - Config.yaml diff --git a/fireflyiii/config.json b/fireflyiii/config.json index edaacb870..f13b7cd16 100644 --- a/fireflyiii/config.json +++ b/fireflyiii/config.json @@ -1,20 +1,27 @@ { "apparmor": true, - "arch": ["aarch64", "amd64", "armv7", "armhf"], + "arch": [ + "aarch64", + "amd64", + "armv7", + "armhf" + ], "boot": "auto", "description": "A free and open source personal finance manager", "devices": [], "environment": { - "TRUSTED_PROXIES": "**", - "DB_DATABASE": "/config/addons_config/fireflyiii/database/database.sqlite" + "TRUSTED_PROXIES": "**" }, - "map": ["config:rw", "share:rw", "ssl"], + "map": [ + "config:rw", + "share:rw", + "ssl" + ], "name": "Firefly iii", "options": { "DB_CONNECTION": "sqlite_internal", "APP_KEY": "CHANGEME_32_CHARS_EuC5dfn3LAPzeO", - "CONFIG_LOCATION": "/config/addons_config/fireflyiii/config.yaml", - "Updates": "daily" + "CONFIG_LOCATION": "/config/addons_config/fireflyiii/config.yaml" }, "ports": { "8080/tcp": 3473 @@ -30,13 +37,14 @@ "DB_PORT": "str?", "DB_DATABASE": "str?", "DB_USERNAME": "str?", - "DB_PASSWORD": "str?", - "Updates": "list(|hourly|daily|weekly)?" + "DB_PASSWORD": "str?" }, "slug": "fireflyiii", - "services": ["mysql:want"], + "services": [ + "mysql:want" + ], "upstream": "5.6.10", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "5.6.10-2", + "version": "5.6.10", "webui": "[PROTO:ssl]://[HOST]:[PORT:8080]" } diff --git a/fireflyiii/rootfs/entrypoint.sh b/fireflyiii/rootfs/entrypoint.sh index ba3d7c058..0a4d34c5f 100644 --- a/fireflyiii/rootfs/entrypoint.sh +++ b/fireflyiii/rootfs/entrypoint.sh @@ -5,7 +5,7 @@ echo "Starting..." # Starting scripts # #################### -for SCRIPTS in /etc/cont-init.d/*; do +for SCRIPTS in /scripts/*; do [ -e "$SCRIPTS" ] || continue echo "$SCRIPTS: executing" chown "$(id -u)":"$(id -g)" "$SCRIPTS" diff --git a/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh deleted file mode 100644 index 29a2a88cc..000000000 --- a/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# If dockerfile failed install manually -if [ -e "/MODULESFILE" ]; then - echo "Executing modules script" - PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); fi && - if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi && - mkdir -p /tmpscripts /etc/cont-init.d && - for scripts in $MODULES; do curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/$scripts" -o /tmpscripts/"$scripts"; done && - if [ -d /etc/cont-init.d ]; then /bin/cp -rf /tmpscripts/* /etc/cont-init.d/ && chmod -R 755 /etc/cont-init.d; fi && - rm -rf /tmpscripts || printf '%s\n' "${MODULES:-}" >/MODULESFILE - ) >/dev/null - -fi - -if [ -e "/ENVFILE" ]; then - echo "Executing script" - PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); fi && - if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi && - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && - chmod 777 /automatic_packages.sh && - eval /./automatic_packages.sh "$PACKAGES" && - rm /automatic_packages.sh - ) >/dev/null - -fi diff --git a/fireflyiii/rootfs/scripts/00-aaa_dockerfile_backup.sh b/fireflyiii/rootfs/scripts/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..1a3fd0934 --- /dev/null +++ b/fireflyiii/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); fi && + if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/fireflyiii/rootfs/scripts/00-banner.sh b/fireflyiii/rootfs/scripts/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/fireflyiii/rootfs/scripts/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/fireflyiii/rootfs/scripts/00-global_var.sh b/fireflyiii/rootfs/scripts/00-global_var.sh new file mode 100644 index 000000000..b68e3f08b --- /dev/null +++ b/fireflyiii/rootfs/scripts/00-global_var.sh @@ -0,0 +1,34 @@ +#!/usr/bin/with-contenv bashio + +################################### +# Export all addon options as env # +################################### + +# For all keys in options.json +JSONSOURCE="/data/options.json" + +# Export keys as env variables +# echo "All addon options were exported as variables" +mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) +for KEYS in "${arr[@]}"; do + # export key + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) + line="${KEYS}=${VALUE//[\"\']/}" + # Use locally + if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi + export $line + # Export the variable to run scripts + line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* +done + +################ +# Set timezone # +################ +if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then + if [ -f /usr/share/zoneinfo/"$TZ" ]; then + echo "Timezone set from $(cat /etc/timezone) to $TZ" + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone + fi +fi + diff --git a/fireflyiii/rootfs/etc/cont-init.d/20-folders.sh b/fireflyiii/rootfs/scripts/20-folders.sh similarity index 100% rename from fireflyiii/rootfs/etc/cont-init.d/20-folders.sh rename to fireflyiii/rootfs/scripts/20-folders.sh diff --git a/fireflyiii/rootfs/etc/cont-init.d/92-config_yaml.sh b/fireflyiii/rootfs/scripts/92-config_yaml.sh similarity index 100% rename from fireflyiii/rootfs/etc/cont-init.d/92-config_yaml.sh rename to fireflyiii/rootfs/scripts/92-config_yaml.sh diff --git a/fireflyiii/rootfs/etc/cont-init.d/99-run.sh b/fireflyiii/rootfs/scripts/99-run.sh similarity index 79% rename from fireflyiii/rootfs/etc/cont-init.d/99-run.sh rename to fireflyiii/rootfs/scripts/99-run.sh index 15885cdb6..83fc8185d 100644 --- a/fireflyiii/rootfs/etc/cont-init.d/99-run.sh +++ b/fireflyiii/rootfs/scripts/99-run.sh @@ -13,7 +13,7 @@ if [ ! ${#APP_KEY} = 32 ]; then bashio::exit.nok "Your APP_KEY has ${#APP_KEY} i # Backup APP_KEY file bashio::log.info "Backuping APP_KEY to /config/addons_config/fireflyiii/APP_KEY_BACKUP.txt" -bashio::log.warning "Changing this value will require to reset your database" +bashio::log.warning "Changing this value will require to reset your database" APP_KEY="$(bashio::config 'APP_KEY')" # Get current app_key @@ -23,7 +23,7 @@ CURRENT=$(sed -e '/^[]*$/d' /config/addons_config/fireflyiii/APP_KEY # Save if new if [ "$CURRENT" != "$APP_KEY" ]; then - echo "$APP_KEY" >>/config/addons_config/fireflyiii/APP_KEY_BACKUP.txt +echo "$APP_KEY" >>/config/addons_config/fireflyiii/APP_KEY_BACKUP.txt fi ################### @@ -38,7 +38,6 @@ sqlite_internal) bashio::log.info "Using built in sqlite" # Set variable export DB_CONNECTION=sqlite - export DB_DATABASE=/config/addons_config/fireflyiii/database/database.sqlite # Creating database mkdir -p /config/addons_config/fireflyiii/database rm -r /var/www/html/storage/database @@ -54,9 +53,9 @@ mariadb_addon) bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting values..." if ! bashio::services.available 'mysql'; then bashio::log.fatal \ - "Local database access should be provided by the MariaDB addon" + "Local database access should be provided by the MariaDB addon" bashio::exit.nok \ - "Please ensure it is installed and started" + "Please ensure it is installed and started" fi # Use values @@ -77,9 +76,9 @@ mariadb_addon) apt-get clean bashio::log.info "Creating database for Firefly-iii if required" mysql \ - -u "${DB_USERNAME}" -p"${DB_PASSWORD}" \ - -h "${DB_HOST}" -P "${DB_PORT}" \ - -e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;" + -u "${DB_USERNAME}" -p"${DB_PASSWORD}" \ + -h "${DB_HOST}" -P "${DB_PORT}" \ + -e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;" ;; # Use remote @@ -95,23 +94,8 @@ mariadb_addon) esac # Install database -bashio::log.info "Updating database" -php artisan migrate --seed >/dev/null -php artisan firefly-iii:upgrade-database >/dev/null - -################ -# CRON OPTIONS # -################ - -# 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 775 /etc/cron.${FREQUENCY}/cronupdate +php artisan migrate --seed +php artisan firefly-iii:upgrade-database ############## # LAUNCH APP # diff --git a/fireflyiii/rootfs/templates/cronupdate b/fireflyiii/rootfs/templates/cronupdate deleted file mode 100644 index 681eb63b7..000000000 --- a/fireflyiii/rootfs/templates/cronupdate +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/local/bin/php /var/www/html/artisan firefly:cron