mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-04 14:54:07 +02:00
Implement logging for OpenVPN with configurable level
Add logging functionality with configurable log level for OpenVPN.
This commit is contained in:
@@ -8,6 +8,7 @@ config["MySelf"]="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BA
|
|||||||
|
|
||||||
declare -a dns_servers_ipv4=()
|
declare -a dns_servers_ipv4=()
|
||||||
declare -a dns_servers_ipv6=()
|
declare -a dns_servers_ipv6=()
|
||||||
|
LOG_LEVEL="$(bashio::config "log_level")"
|
||||||
|
|
||||||
_parse_config() {
|
_parse_config() {
|
||||||
local -n config_ref="$1"
|
local -n config_ref="$1"
|
||||||
@@ -346,12 +347,20 @@ _openvpn_up() {
|
|||||||
echo "${config["MySelf"]} openvpn postdown" >> ${config["PostDownScript"]}
|
echo "${config["MySelf"]} openvpn postdown" >> ${config["PostDownScript"]}
|
||||||
chmod 755 ${config["PostDownScript"]}
|
chmod 755 ${config["PostDownScript"]}
|
||||||
|
|
||||||
|
# Define logging
|
||||||
|
LOG_PATH="/dev/null"
|
||||||
|
if [[ "$LOG_LEVEL" == "debug" ]]; then
|
||||||
|
bashio::log.warning "Starting openvpn in debug mode"
|
||||||
|
bashio::log.warning "------------------------------"
|
||||||
|
LOG_PATH="/proc/1/fd/1"
|
||||||
|
fi
|
||||||
|
|
||||||
# Start OpenVPN in the background
|
# Start OpenVPN in the background
|
||||||
_cmd "/usr/sbin/openvpn \
|
_cmd "/usr/sbin/openvpn \
|
||||||
--config "${config["ConfigFile"]}" \
|
--config "${config["ConfigFile"]}" \
|
||||||
--client \
|
--client \
|
||||||
--daemon \
|
--daemon \
|
||||||
--log /dev/null \
|
--log "$LOG_PATH" \
|
||||||
--script-security 2 \
|
--script-security 2 \
|
||||||
--auth-user-pass "${OPENVPN_STATE_DIR}/credentials.conf" \
|
--auth-user-pass "${OPENVPN_STATE_DIR}/credentials.conf" \
|
||||||
--auth-retry none \
|
--auth-retry none \
|
||||||
|
|||||||
Reference in New Issue
Block a user