From 175d195763b7e68ce22dac37a76611a247c0d9ac Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:08:36 +0100 Subject: [PATCH] Use own ssl certificates --- webtop_kde/rootfs/etc/cont-init.d/90-ssl.sh | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 webtop_kde/rootfs/etc/cont-init.d/90-ssl.sh diff --git a/webtop_kde/rootfs/etc/cont-init.d/90-ssl.sh b/webtop_kde/rootfs/etc/cont-init.d/90-ssl.sh new file mode 100644 index 000000000..24313528c --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/90-ssl.sh @@ -0,0 +1,22 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +set -e + +if bashio::config.true 'use_own_certs'; then + bashio::log.green "Using referenced ssl certificates. Please remember to open the ssl port in the addon options" + CERTFILE=$(bashio::config 'certfile') + KEYFILE=$(bashio::config 'keyfile') + + # Validate ssl + bashio::config.require.ssl + + #Check if files exist + echo "... checking if referenced files exist" + [ ! -f /ssl/"$CERTFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$CERTFILE not found" && bashio::exit.nok + [ ! -f /ssl/"$KEYFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$KEYFILE not found" && bashio::exit.nok + + + # Add ssl file + sed -i "s|/config/data/ssl/cert.pem|/ssl/$(bashio::config 'certfile')|g" "$NGINX_CONFIG" + sed -i "s|/config/data/ssl/cert.key|/ssl/$(bashio::config 'keyfile')|g" "$NGINX_CONFIG" +fi