Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Commit

Permalink
⬆️ Upgrade to base 3.0.0 and migrate to bashio
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Mar 19, 2019
1 parent 6acf0cc commit 37d7819
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 82 deletions.
11 changes: 6 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ variables:
ADDON_SLUG: "matrix"
ADDON_TARGET: "matrix"

ADDON_ARMV7: "false"
ADDON_LEGACY_TAGS: "true"

ADDON_AARCH64_BASE: "hassioaddons/base-aarch64:2.3.2"
ADDON_AMD64_BASE: "hassioaddons/base-amd64:2.3.2"
ADDON_ARMHF_BASE: "hassioaddons/base-armhf:2.3.2"
ADDON_I386_BASE: "hassioaddons/base-i386:2.3.2"
ADDON_AARCH64_BASE: "hassioaddons/base-aarch64:3.0.0"
ADDON_AMD64_BASE: "hassioaddons/base-amd64:3.0.0"
ADDON_ARMHF_BASE: "hassioaddons/base-armhf:3.0.0"
ADDON_ARMV7_BASE: "hassioaddons/base-armv7:3.0.0"
ADDON_I386_BASE: "hassioaddons/base-i386:3.0.0"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ The private key file to use for SSL.
### Option: `server_name`

This is the hostname of your server. Set this to the host that you will be
connecting to with your clients without the port and without `http://` /
`https://`. For example: if your domain name is `home-assistant.io` set your
`server_name` to this.
connecting to with your clients without the port and without the
`http://` or`https://`. For example: if your domain name is
`home-assistant.io` set your `server_name` to this.

**Note**: _You should only set this once. You will likely have to reinstall the
addon to change this after the fact, losing all your rooms and users._
Expand Down
29 changes: 15 additions & 14 deletions matrix/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_FROM=hassioaddons/base:2.3.2
ARG BUILD_FROM=hassioaddons/base:3.0.0
# hadolint ignore=DL3006
FROM ${BUILD_FROM}

Expand All @@ -9,34 +9,35 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \
apk add --no-cache --virtual .build-dependencies \
build-base=0.5-r1 \
libffi-dev=3.2.1-r4 \
libffi-dev=3.2.1-r6 \
libjpeg-turbo-dev=1.5.3-r4 \
libressl-dev=2.7.5-r0 \
libxslt-dev=1.1.32-r0 \
linux-headers=4.4.6-r2 \
postgresql-dev=10.5-r0 \
python3-dev=3.6.6-r0 \
linux-headers=4.18.13-r1 \
musl-dev=1.1.20-r4 \
postgresql-dev=11.1-r0 \
python3-dev=3.6.8-r1 \
zlib-dev=1.2.11-r1 \
\
&& apk add --no-cache \
libffi=3.2.1-r4 \
libffi=3.2.1-r6 \
libjpeg-turbo=1.5.3-r4 \
libpq=10.5-r0 \
libpq=11.1-r0 \
libressl=2.7.5-r0 \
libxslt=1.1.32-r0 \
nginx=1.14.2-r0 \
py3-lxml=4.2.2-r0 \
py3-msgpack=0.5.6-r0 \
py3-pillow=4.3.0-r0 \
py3-lxml=4.2.5-r0 \
py3-msgpack=0.6.1-r0 \
py3-pillow=5.4.1-r0 \
py3-psycopg2=2.7.5-r0 \
py3-pynacl=1.2.1-r1\
py3-setuptools=39.1.0-r0 \
py3-pynacl=1.3.0-r1 \
py3-setuptools=40.6.3-r0 \
py3-six=1.11.0-r0 \
python3=3.6.6-r0 \
python3=3.6.8-r1 \
su-exec=0.2-r0 \
zlib=1.2.11-r1 \
\
&& pip3 install --upgrade pip==19.0.1 \
&& pip3 install --upgrade pip==19.0.3 \
&& pip3 install \
pysaml2==4.6.5 \
matrix-synapse==0.99.2 \
Expand Down
9 changes: 5 additions & 4 deletions matrix/build.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"args": {},
"build_from": {
"aarch64": "hassioaddons/base-aarch64:2.3.2",
"amd64": "hassioaddons/base-amd64:2.3.2",
"armhf": "hassioaddons/base-armhf:2.3.2",
"i386": "hassioaddons/base-i386:2.3.2"
"aarch64": "hassioaddons/base-aarch64:3.0.0",
"amd64": "hassioaddons/base-amd64:3.0.0",
"armhf": "hassioaddons/base-armhf:3.0.0",
"armv7": "hassioaddons/base-armv7:3.0.0",
"i386": "hassioaddons/base-i386:3.0.0"
}
}
1 change: 1 addition & 0 deletions matrix/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"aarch64",
"amd64",
"armhf",
"armv7",
"i386"
],
"boot": "auto",
Expand Down
34 changes: 10 additions & 24 deletions matrix/rootfs/etc/cont-init.d/10-requirements.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Matrix
# This files check if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL settings
bashio::config.require.ssl

# 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

if ! hass.config.has_value 'server_name'; then
hass.die 'You must specify your server name! E.g.: yourddns_url.com'
if ! bashio::config.has_value 'server_name'; then
bashio::log.fatal ''
bashio::log.fatal 'You must specify your server name!'
bashio::log.fatal 'This should be the hostname of your server'
bashio::log.fatal 'without "http://" / "https://" and the port.'
bashio::log.fatal 'Refer to the "server_name" option in the docs for more info.'
bashio::exit.nok
fi
29 changes: 14 additions & 15 deletions matrix/rootfs/etc/cont-init.d/20-synapse.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Matrix
# Configures the Matrix Synapse server
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh

declare server_name
server_name=$(hass.config.get 'server_name')
server_name=$(bashio::config 'server_name')

if hass.file_exists "/config/matrix.yaml"; then
if bashio::fs.file_exists "/config/matrix.yaml"; then
declare old_name
old_name=$(yq read /config/matrix.yaml 'server_name')
if [[ "$old_name" != "$server_name" ]]; then
hass.log.fatal "The server_name has changed!"
hass.log.fatal "Are you sure you want to do this?"
hass.log.fatal "If so, delete the 'matrix.yaml' file located in '/config' and restart the addon."
hass.die "WARNING: This will remove all rooms, users, chats and start afresh."
bashio::log.fatal ''
bashio::log.fatal 'The server_name has changed!'
bashio::log.fatal 'Are you sure you want to do this?'
bashio::log.fatal 'If so, delete the "matrix.yaml" file located in "/config" and restart the addon.'
bashio::log.fatal 'WARNING: This will remove all rooms, users, chats and start afresh.'
bashio::exit.nok
fi
fi

if ! hass.file_exists "/config/matrix.yaml"; then
hass.log.info "Config file at '/config/matrix.yaml' does not exist. Creating.."
if ! bashio::fs.file_exists "/config/matrix.yaml"; then
bashio::log.info "Config file at '/config/matrix.yaml' does not exist. Creating.."

rm -f /share/matrix/matrix.db

Expand All @@ -41,11 +40,11 @@ if ! hass.file_exists "/config/matrix.yaml"; then
yq write --inplace /config/matrix.yaml 'max_upload_size' '200M'
fi

if hass.config.true 'ssl'; then
if bashio::config.true 'ssl'; then
yq write --inplace /config/matrix.yaml 'no_tls' false
yq write --inplace /config/matrix.yaml 'listeners[0].tls' true
yq write --inplace /config/matrix.yaml 'tls_certificate_path' "/ssl/$(hass.config.get 'certfile')"
yq write --inplace /config/matrix.yaml 'tls_private_key_path' "/ssl/$(hass.config.get 'keyfile')"
yq write --inplace /config/matrix.yaml 'tls_certificate_path' "/ssl/$(bashio::config 'certfile')"
yq write --inplace /config/matrix.yaml 'tls_private_key_path' "/ssl/$(bashio::config 'keyfile')"
else
yq write --inplace /config/matrix.yaml 'no_tls' true
yq write --inplace /config/matrix.yaml 'listeners[0].tls' false
Expand Down
11 changes: 4 additions & 7 deletions matrix/rootfs/etc/cont-init.d/40-nginx.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Matrix
# Configures NGINX for use with Riot
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh

declare certfile
declare keyfile

# Enable SSL
if hass.config.true 'ssl'; then
certfile=$(hass.config.get 'certfile')
keyfile=$(hass.config.get 'keyfile')
if bashio::config.true 'ssl'; then
certfile=$(bashio::config 'certfile')
keyfile=$(bashio::config 'keyfile')

sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx-ssl.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx-ssl.conf
Expand Down
5 changes: 1 addition & 4 deletions matrix/rootfs/etc/services.d/matrix/run
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/with-contenv bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Matrix
# Runs the Synapse daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh

exec python3.6 -B -m synapse.app.homeserver -c /config/matrix.yaml
9 changes: 3 additions & 6 deletions matrix/rootfs/etc/services.d/nginx/run
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/bin/bash
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Community Hass.io Add-ons: Matrix
# Runs the NGINX daemon for Riot
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh

hass.log.info "Starting NGINX for Riot..."
if hass.config.true 'ssl'; then
bashio::log.info "Starting NGINX for Riot..."
if bashio::config.true 'ssl'; then
options='/etc/nginx/nginx-ssl.conf'
else
options='/etc/nginx/nginx.conf'
Expand Down

0 comments on commit 37d7819

Please sign in to comment.