Add add-on code and setup

This commit is contained in:
Timmo 2019-02-09 22:10:01 +00:00
parent de00efb9da
commit f4500ad10d
8 changed files with 187 additions and 0 deletions

42
thelounge/Dockerfile Normal file
View file

@ -0,0 +1,42 @@
ARG BUILD_FROM=hassioaddons/base:2.3.1
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Install packages
# hadolint ignore=DL3003
RUN \
apk add --no-cache \
nodejs-current=9.11.1-r2 \
yarn=1.7.0-r0 \
\
&& yarn global add thelounge@3.0.0 \
\
&& yarn cache clean \
&& rm -fr /tmp/*
# Copy root filesystem
COPY rootfs /
# Build arguments
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="The Lounge" \
io.hass.description="A self-hosted web IRC client" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Timmo <contact@timmo.xyz>" \
org.label-schema.description="A self-hosted web IRC client" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="The Lounge" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://community.home-assistant.io/?u=timmo001" \
org.label-schema.usage="https://github.com/hassio-addons/addon-thelounge/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-thelounge" \
org.label-schema.vendor="Community Hass.io Add-ons"

10
thelounge/build.json Normal file
View file

@ -0,0 +1,10 @@
{
"args": {},
"build_from": {
"aarch64": "hassioaddons/base-aarch64:2.3.1",
"amd64": "hassioaddons/base-amd64:2.3.1",
"armhf": "hassioaddons/base-armhf:2.3.1",
"i386": "hassioaddons/base-i386:2.3.1"
},
"squash": false
}

50
thelounge/config.json Normal file
View file

@ -0,0 +1,50 @@
{
"name": "The Lounge",
"version": "dev",
"slug": "thelounge",
"description": "A self-hosted web IRC client",
"url": "https://github.com/hassio-addons/addon-thelounge",
"webui": "[PROTO:ssl]://[HOST]:[PORT:15100]",
"startup": "application",
"arch": [
"aarch64",
"amd64",
"armhf",
"i386"
],
"boot": "auto",
"hassio_api": true,
"hassio_role": "default",
"homeassistant_api": true,
"host_network": false,
"ports": {
"15100/tcp": 15100
},
"map": [
"config:rw",
"ssl"
],
"options": {
"log_level": "info",
"ssl": true,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"default_theme": "default",
"themes": [
"thelounge-theme-material"
]
},
"schema": {
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"default_theme": "str",
"themes": [
"str"
]
},
"environment": {
"LOG_FORMAT": "{LEVEL}: {MESSAGE}"
}
}

View file

@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: The Lounge
# This checks if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL requirements, if enabled
if hass.config.true 'ssl'; then
if ! hass.config.has_value 'certfile'; then
hass.die 'SSL is enabled, but no certfile was specified'
fi
if ! hass.config.has_value 'keyfile'; then
hass.die 'SSL is enabled, but no keyfile was specified'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then
hass.die 'The configured certfile is not found'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
hass.die 'The configured keyfile is not found'
fi
fi

View file

@ -0,0 +1,20 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: The Lounge
# This adds the default user and installs any requested themes
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
export THELOUNGE_HOME=/data/thelounge
if ! hass.directory_exists "/data/thelounge"; then
hass.log.info "Creating default hassio user.."
mkdir -p /data/thelounge/users
cp /etc/thelounge/users/hassio.json /data/thelounge/users
else
for theme in $(hass.config.get "themes")
do
/usr/local/bin/thelounge install "$theme"
done
fi

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: The Lounge
# Take down the S6 supervision tree when NGINX fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,22 @@
#!/bin/bash
# ==============================================================================
# Community Hass.io Add-ons: The Lounge
# Runs The Lounge
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
export THELOUNGE_HOME=/data/thelounge
hass.log.info "Starting The Lounge server.."
exec /usr/local/bin/thelounge start \
-c port=15100 \
-c https.enable="$(hass.config.get 'ssl')" \
-c https.ca="/ssl/$(hass.config.get 'certfile')" \
-c https.certificate="/ssl/$(hass.config.get 'certfile')" \
-c https.key="/ssl/$(hass.config.get 'keyfile')" \
-c fileUpload=true \
-c prefetch=true \
-c prefetchStorage=true \
-c theme="$(hass.config.get 'default_theme')"

View file

@ -0,0 +1,8 @@
{
"password": "$2a$11$yq4ZxpU9QYlVvqGPX86KauLBPJVcJUlhSBFyCAzQ8XAguTmsv/Nr2",
"log": true,
"awayMessage": "",
"networks": [],
"sessions": {},
"clientSettings": {}
}