This commit is contained in:
Alexandre
2024-12-06 11:13:40 +01:00
parent ebeba185b2
commit bdef93601c
11 changed files with 359 additions and 0 deletions

1
monica/CHANGELOG.md Normal file
View File

@@ -0,0 +1 @@

114
monica/Dockerfile Normal file
View File

@@ -0,0 +1,114 @@
#============================#
# ALEXBELGIUM'S DOCKERFILE #
#============================#
# _.------.
# _.-` ('>.-`"""-.
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# '---` .-'""`
# /`
#=== Home Assistant Addon ===#
#################
# 1 Build Image #
#################
ARG BUILD_VERSION
ARG BUILD_FROM
FROM ${BUILD_FROM}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
##################
# 2 Modify Image #
##################
# Set S6 wait time
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
##################
# 3 Install apps #
##################
# Add rootfs
COPY rootfs/ /
# Uses /bin for compatibility purposes
# hadolint ignore=DL4005
RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \
if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi
# Modules
ARG MODULES=""
# Automatic modules download
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" "/ha_automodules.sh"
RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh
# Manual apps
ENV PACKAGES=""
# Automatic apps & bashio
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh"
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
################
# 4 Entrypoint #
################
# Add entrypoint
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh"
# Entrypoint modifications
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh"
RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh
WORKDIR /config
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENTRYPONT [ /ha_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}
#################
# 6 Healthcheck #
#################
ENV HEALTH_PORT="80" \
HEALTH_URL=""
HEALTHCHECK \
--interval=5s \
--retries=5 \
--start-period=30s \
--timeout=25s \
CMD curl --fail "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" &>/dev/null || exit 1

1
monica/README.md Normal file
View File

@@ -0,0 +1 @@
# Home assistant add-on: monica

66
monica/apparmor.txt Normal file
View File

@@ -0,0 +1,66 @@
#include <tunables/global>
profile monica_addon flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
capability,
file,
signal,
mount,
umount,
remount,
network udp,
network tcp,
network dgram,
network stream,
network inet,
network inet6,
network netlink raw,
network unix dgram,
capability setgid,
capability setuid,
capability sys_admin,
capability dac_read_search,
# capability dac_override,
# capability sys_rawio,
# S6-Overlay
/init ix,
/run/{s6,s6-rc*,service}/** ix,
/package/** ix,
/command/** ix,
/run/{,**} rwk,
/dev/tty rw,
/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/fuse mrwkl,
/dev/sda1 mrwkl,
/dev/sdb1 mrwkl,
/dev/nvme0 mrwkl,
/dev/nvme1 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,
}

6
monica/build.yaml Normal file
View File

@@ -0,0 +1,6 @@
---
build_from:
aarch64: monica:5.0-apache
amd64: monica:5.0-apache
codenotary:
signer: alexandrep.github@gmail.com

92
monica/config.json Normal file
View File

@@ -0,0 +1,92 @@
arch:
- aarch64
- amd64
codenotary: alexandrep.github@gmail.com
description: Personal Relationship Manager
devices:
- "/dev/dri"
- "/dev/dri/card0"
- "/dev/dri/card1"
- "/dev/dri/renderD128"
- "/dev/vchiq"
- "/dev/video10"
- "/dev/video11"
- "/dev/video12"
- "/dev/video13"
- "/dev/video14"
- "/dev/video15"
- "/dev/video16"
- "/dev/ttyUSB0"
- "/dev/sda"
- "/dev/sdb"
- "/dev/sdc"
- "/dev/sdd"
- "/dev/sde"
- "/dev/sdf"
- "/dev/sdg"
- "/dev/nvme"
- "/dev/nvme0n1p1"
- "/dev/nvme0n1p2"
- "/dev/nvme0n1p3"
- "/dev/nvme1n1p1"
- "/dev/nvme1n1p2"
- "/dev/nvme1n1p3"
- "/dev/nvme2n1p1"
- "/dev/nvme2n1p2"
- "/dev/nvme3n1p3"
- "/dev/mmcblk"
- "/dev/fuse"
- "/dev/sda1"
- "/dev/sdb1"
- "/dev/sdc1"
- "/dev/sdd1"
- "/dev/sde1"
- "/dev/sdf1"
- "/dev/sdg1"
- "/dev/sda2"
- "/dev/sdb2"
- "/dev/sdc2"
- "/dev/sdd2"
- "/dev/sde2"
- "/dev/sdf2"
- "/dev/sdg2"
- "/dev/sda3"
- "/dev/sdb3"
- "/dev/sda4"
- "/dev/sdb4"
- "/dev/sda5"
- "/dev/sda6"
- "/dev/sda7"
- "/dev/sda8"
- "/dev/nvme0"
- "/dev/nvme1"
- "/dev/nvme2"
environment: {}
image: ghcr.io/alexbelgium/monica-{arch}
init: false
options: {
"APP_KEY": "empty"
}
map:
- type: addon_config
read_only: false
path: /var/www/html/storage
name: Monica
ports:
8080/tcp: 8181
ports_description:
8080/tcp: webui
schema: {
"APP_KEY": "str?",
"DB_DATABASE": "str?",
"DB_HOST": "str?",
"DB_PASSWORD": "str?",
"DB_PORT": "int?",
"DB_USERNAME": "str?"
}
services:
- mysql:want
slug: monica
url: https://github.com/alexbelgium/hassio-addons/tree/master/monica
version: test
webui: "[PROTO:ssl]://[HOST]:[PORT:8080]"

BIN
monica/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
monica/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@@ -0,0 +1,68 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
# Gives mariadb information
###################
# Define database #
###################
bashio::log.info "Defining database"
DB_DATABASE="$(bashio::config 'DB_DATABASE')"
DB_HOST="$(bashio::config 'DB_HOST')"
DB_PASSWORD="$(bashio::config 'DB_PASSWORD')"
DB_PORT="$(bashio::config 'DB_PORT')"
DB_USERNAME="$(bashio::config 'DB_USERNAME')"
# Check if at least one variable is not empty
if [ -n "$DB_DATABASE" ] || [ -n "$DB_HOST" ] || [ -n "$DB_PASSWORD" ] || [ -n "$DB_PORT" ] || [ -n "$DB_USERNAME" ]; then
# Alert if mariadb is available
if bashio::services.available 'mysql'; then
bashio::log.warning "The MariaDB addon is available, but you have selected to use your own database by manually configuring the addon options"
fi
# Verify all variables are not empty
if [ -z "$DB_DATABASE" ] || [ -z "$DB_HOST" ] || [ -z "$DB_PASSWORD" ] || [ -z "$DB_PORT" ] || [ -z "$DB_USERNAME" ]; then
bashio::log.fatal "You have selected to not use the automatic Mariadb detection by manually configuring the addon options, but not all. Ensure all are set: DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_USERNAME."
exit 1
fi
else
# User Mariadb
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..."
if ! bashio::services.available 'mysql'; then
bashio::log.fatal \
"Local database access should be provided by the MariaDB addon"
bashio::exit.nok \
"Please ensure it is installed and started"
fi
# Use values
export DB_HOST=$(bashio::services "mysql" "host") && bashio::log.blue "DB_HOST=$DB_HOST" && sed "1a export DB_HOST=$DB_HOST" /usr/local/bin/entrypoint.sh
export DB_PORT=$(bashio::services "mysql" "port") && bashio::log.blue "DB_PORT=$DB_PORT" && sed "1a export DB_PORT=$DB_PORT" /usr/local/bin/entrypoint.sh
export DB_DATABASE=monica && bashio::log.blue "DB_DATABASE=$DB_DATABASE" && sed "1a export DB_DATABASE=$DB_DATABASE" /usr/local/bin/entrypoint.sh
export DB_USERNAME=$(bashio::services "mysql" "username") && bashio::log.blue "DB_USERNAME=$DB_USERNAME" && sed "1a export DB_USERNAME=$DB_USERNAME" /usr/local/bin/entrypoint.sh
export DB_PASSWORD=$(bashio::services "mysql" "password") && bashio::log.blue "DB_PASSWORD=$DB_PASSWORD" && sed "1a export DB_PASSWORD=$DB_PASSWORD" /usr/local/bin/entrypoint.sh
bashio::log.warning "Monica is using the Maria DB addon"
bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
fi
###########
# APP_KEY #
###########
if [ ${#APP_KEY:=$(bashio::config "APP_KEY")} -ne 32 ]; then
APP_KEY="$(echo -n 'base64:'; openssl rand -base64 32)"
bashio::addon.option "APP_KEY" "${APP_KEY}"
bashio::log.warning "The APP_KEY set was invalid, generated a random one: ${APP_KEY}. Restarting to take it into account"
echo "${APP_KEY}" >> /config/APP_KEY
bashio::addon.restart
fi
export APP_KEY="$(bashio::config "APP_KEY")"
bashio::log.info "Starting Monica"
/./usr/local/bin/entrypoint.sh

BIN
monica/stats.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

11
monica/updater.json Normal file
View File

@@ -0,0 +1,11 @@
{
"dockerhub_by_date": true,
"dockerhub_list_size": 20,
"github_tagfilter": "apache",
"last_update": "16-11-2024",
"repository": "alexbelgium/hassio-addons",
"slug": "monica",
"source": "dockerhub",
"upstream_repo": "monica",
"upstream_version": "5.0-apache"
}