mosquitto: Set mosquitto.conf log_type based on logging level (#1708)

* config option for mosquitto log_type

* change log_type to be based on LOGGING

* remove extra whitespace

* use bashio::log.<level> for logging

* set run.sh and auth_srv.sh bashio logging level to match supervisor level

* lint fixes

* Update mosquitto/data/auth_srv.sh

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>

* HomeMatic: s6-overlay & tempio (#1713)

* HomeMatic: s6-overlay & tempio

* Use tempio

* fix line end

* Fix dev version

* Fix bugs

* S6-overlay cleanup for HM & deCONZ (#1717)

* HomeMatic: take container down on ReGaHss (#1719)

* HomeMatic: Fix ingress (#1720)

* HomeMatic: Fix ingress

* Fix count

* Fix template HM

* set run.sh and auth_srv.sh bashio logging level to match supervisor level

* lint fixes

* Update mosquitto/data/auth_srv.sh

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
b3nj1
2021-02-08 07:00:32 -08:00
committed by GitHub
parent a114116980
commit d291f564ce
3 changed files with 18 additions and 5 deletions

View File

@@ -1,11 +1,13 @@
#!/bin/bash
#!/usr/bin/env bashio
# shellcheck disable=SC2244,SC1117
set +u
set -e
CONFIG_PATH=/data/options.json
SYSTEM_USER=/data/system_user.json
REQUEST=()
REQUEST_BODY=""
LOGGING=$(bashio::info.logging)
declare -A LOCAL_DB
@@ -81,6 +83,7 @@ function get_var() {
## MAIN ##
bashio::log.level "${LOGGING}"
read_request
@@ -97,10 +100,10 @@ password="$(get_var password)"
# If local user
if [ "${LOCAL_DB["${username}"]}" == "${password}" ]; then
echo "[INFO] found ${username} on local database" >&2
bashio::log.info "[INFO] found ${username} on local database"
http_ok
elif [ ${LOCAL_DB["${username}"]+_} ]; then
echo "[WARN] Not found ${username} on local database" >&2
bashio::log.warning "[WARN] Not found ${username} on local database"
http_error
fi
@@ -109,9 +112,9 @@ auth_header="X-Hassio-Key: ${HASSIO_TOKEN}"
content_type="Content-Type: application/x-www-form-urlencoded"
if curl -s -f -X POST -d "${REQUEST_BODY}" -H "${content_type}" -H "${auth_header}" http://hassio/auth > /dev/null; then
echo "[INFO] found ${username} on Home Assistant" >&2
bashio::log.info "[INFO] found ${username} on Home Assistant"
http_ok
fi
echo "[ERROR] Auth error with ${username}" >&2
bashio::log.error "[ERROR] Auth error with ${username}"
http_error

View File

@@ -6,6 +6,10 @@ user root
##
# logging
log_dest stdout
log_type error
log_type warning
log_type notice
log_type information
##
# datastore

View File

@@ -84,6 +84,7 @@ function constrain_discovery() {
}
## Main ##
bashio::log.level "${LOGGING}"
bashio::log.info "Setup mosquitto configuration"
sed -i "s/%%ANONYMOUS%%/$ANONYMOUS/g" /etc/mosquitto.conf
@@ -92,6 +93,11 @@ if [ "${LOGGING}" == "debug" ]; then
sed -i "s/%%AUTH_QUIET_LOGS%%/false/g" /etc/mosquitto.conf
else
sed -i "s/%%AUTH_QUIET_LOGS%%/true/g" /etc/mosquitto.conf
if [ "${LOGGING}" == "critical" ] || [ "${LOGGING}" == "fatal" ] || [ "${LOGGING}" == "error" ]; then
sed -i -e "s/^log_type warning//" -e "s/^log_type notice//" -e "s/^log_type information//" /etc/mosquitto.conf
elif [ "${LOGGING}" == "warning" ] || [ "${LOGGING}" == "warn" ]; then
sed -i -e "s/^log_type notice//" -e "s/^log_type information//" /etc/mosquitto.conf
fi
fi
# Enable SSL if exists configs