This commit is contained in:
Alexandre
2021-12-29 11:07:14 +01:00
parent 50ea9cd968
commit ae11665574
14 changed files with 355 additions and 0 deletions

View File

@@ -0,0 +1 @@
- Initial release

View File

@@ -0,0 +1,84 @@
#==========================#
# ALEXBELGIUM'S DOCKERFILE #
#==========================#
#           _.------.
#       _.-`    ('>.-`"""-.
# '.--'`       _'`   _ .--.)
#    -'         '-.-';`   `
#    ' -      _.'  ``'--. 
#        '---`    .-'""`
#               /`
#################
# 1 Build Image #
#################
ARG BUILD_FROM
ARG BUILD_VERSION
FROM ${BUILD_FROM}
##################
# 2 Modify Image #
##################
#ENV FIREFLY_III_PATH="/data/firefly"
#WORKDIR $FIREFLY_III_PATH
#RUN \
# # Change data location
# grep -rl "/var/www/html" /etc/ | xargs sed -i 's|/var/www/html|/data/firefly|g'
##################
# 3 Install apps #
##################
# Copy local files
COPY rootfs/ /
# Manual apps
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 && \
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 && \
/automatic_packages.sh "${PACKAGES:-}" && \
rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE
################
# 4 Entrypoint #
################
RUN chmod 777 /entrypoint.sh
ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/entrypoint.sh" ]
############
# 5 Labels #
############
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Add-ons" \
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

View File

@@ -0,0 +1,59 @@
# Home assistant add-on: Fireflyiii data importer
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
![Supports
Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield]
![Supports smb mounts][smb-shield]
_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_
[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers)
## About
["Firefly III"](https://www.firefly-iii.org) is a (self-hosted) manager for your personal finances. It can help you keep track of your expenses and income, so you can spend less and save more. The data importer is built to help you import transactions into Firefly III. It is separated from Firefly III for security and maintenance reasons.
This addon is based on the docker image https://hub.docker.com/r/fireflyiii/data-importer
## Configuration
Read official documentation for more information : https://docs.firefly-iii.org/data-importer
```yaml
"FIREFLY_III_ACCESS_TOKEN": required to access Firefly
"FIREFLY_III_CLIENT_ID": alternative way to access Firefly
"FIREFLY_III_URL": your url, either local (docker IP), or external (public IP)
"NORDIGEN_ID": your Nordigen Client ID
"NORDIGEN_KEY": your Nordigen Client Secret
"SPECTRE_APP_ID": your Spectre / Salt Edge Client ID
"SPECTRE_SECRET": your Spectre / Salt Edge Client secret
```
## Installation
The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on.
1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA)
[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons)
1. Install this add-on.
1. Click the `Save` button to store your configuration.
1. Set the add-on options to your preferences
1. Start the add-on.
1. Check the logs of the add-on to see if everything went well.
1. Open the webUI and adapt the software options
## Support
Create an issue on github
## Illustration
[repository]: https://github.com/alexbelgium/hassio-addons
[smb-shield]: https://img.shields.io/badge/smb-yes-green.svg
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg

View File

@@ -0,0 +1,48 @@
#include <tunables/global>
profile fireflyiii_addon flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
capability,
file,
mount,
umount,
remount,
capability setgid,
capability setuid,
capability sys_admin,
capability dac_read_search,
# capability dac_override,
# capability sys_rawio,
# S6-Overlay
/bin/** ix,
/usr/bin/** ix,
/usr/lib/bashio/** ix,
/etc/s6/** rix,
/run/s6/** rix,
/etc/services.d/** rwix,
/etc/cont-init.d/** rwix,
/etc/cont-finish.d/** rwix,
/init rix,
/var/run/** mrwkl,
/var/run/ mrwkl,
/dev/i2c-1 mrwkl,
# Files required
/dev/sda1 mrwkl,
/dev/sdb1 mrwkl,
/dev/mmcblk0p1 mrwkl,
/dev/* mrwkl,
/tmp/** mrkwl,
# Data access
/data/** rw,
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
ptrace (trace,read) peer=docker-default,
# docker daemon confinement requires explict allow rule for signal
signal (receive) set=(kill,term) peer=/usr/bin/docker,
}

View File

@@ -0,0 +1,8 @@
{
"build_from": {
"armhf": "fireflyiii/data-importer:latest",
"armv7": "fireflyiii/data-importer:latest",
"aarch64": "fireflyiii/data-importer:latest",
"amd64": "fireflyiii/data-importer:latest"
}
}

View File

@@ -0,0 +1,33 @@
{
"apparmor": true,
"arch": ["aarch64", "amd64", "armv7", "armhf"],
"boot": "auto",
"description": "Data importer for Firefly III (separate addon)",
"devices": [],
"environment": {
"TRUSTED_PROXIES": "**"
},
"map": ["config:rw", "share:rw", "ssl"],
"name": "Firefly iii Data Importer",
"options": {},
"ports": {
"8080/tcp": 3474
},
"ports_description": {
"8080/tcp": "web interface"
},
"schema": {
"FIREFLY_III_ACCESS_TOKEN": "str",
"FIREFLY_III_URL": "str",
"FIREFLY_III_CLIENT_ID": "str?",
"NORDIGEN_ID": "str?",
"NORDIGEN_KEY": "str?",
"SPECTRE_APP_ID": "str?",
"SPECTRE_SECRET": "str?"
},
"slug": "fireflyiii_data_importer",
"upstream": "0.4.1",
"url": "https://github.com/alexbelgium/hassio-addons",
"version": "0.4.1",
"webui": "[PROTO:ssl]://[HOST]:[PORT:8080]"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@@ -0,0 +1,16 @@
#!/bin/bash
echo "Starting..."
####################
# Starting scripts #
####################
for SCRIPTS in /scripts/*; do
[ -e "$SCRIPTS" ] || continue
echo "$SCRIPTS: executing"
chown $(id -u):$(id -g) $SCRIPTS
chmod a+x $SCRIPTS
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true
/./$SCRIPTS || echo "$SCRIPTS: exiting $?"
done

View File

@@ -0,0 +1,18 @@
#!/bin/bash
# If dockerfile failed install manually
if [ -e "/ENVFILE" ]; then
echo "Executing script"
PACKAGES=$(</ENVFILE)
(
#######################
# Automatic installer #
#######################
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 &&
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

View File

@@ -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

View File

@@ -0,0 +1,33 @@
#!/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

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bashio
# Create directory
mkdir -p /config/addons_config/fireflyiii_data_importer
# Make sure permissions are right
chown -R $(id -u):$(id -g) /config/addons_config/fireflyiii_data_importer

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bashio
##############
# LAUNCH APP #
##############
bashio::log.info "Please wait while the app is loading !"
/./usr/local/bin/entrypoint.sh