mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-17 19:40:31 +02:00
config selection logic fix
This commit is contained in:
@@ -42,10 +42,9 @@ fi
|
||||
echo -e "${openvpn_username}\n${openvpn_password}" > "${OPENVPN_STATE_DIR}/credentials.conf"
|
||||
chmod 600 "${OPENVPN_STATE_DIR}/credentials.conf"
|
||||
|
||||
if bashio::config.has_value 'openvpn_config'; then
|
||||
openvpn_config="$(bashio::config 'openvpn_config')"
|
||||
openvpn_config="${openvpn_config##*/}"
|
||||
if [[ -z "${openvpn_config}" ]]; then
|
||||
openvpn_config="$(bashio::config 'openvpn_config')"
|
||||
openvpn_config="${openvpn_config##*/}"
|
||||
if [[ -z "${openvpn_config}" ]]; then
|
||||
bashio::log.info 'openvpn_config option left empty. Attempting automatic selection.'
|
||||
mapfile -t configs < <(find /config/openvpn -maxdepth 1 \( -type f -name '*.conf' -o -name '*.ovpn' \) -print)
|
||||
if [ "${#configs[@]}" -eq 0 ]; then
|
||||
@@ -59,11 +58,10 @@ if bashio::config.has_value 'openvpn_config'; then
|
||||
else
|
||||
bashio::exit.nok "Multiple OpenVPN configuration files detected. Please set the 'openvpn_config' option."
|
||||
fi
|
||||
elif bashio::fs.file_exists "/config/openvpn/${openvpn_config}"; then
|
||||
elif bashio::fs.file_exists "/config/openvpn/${openvpn_config}"; then
|
||||
openvpn_config="/config/openvpn/${openvpn_config}"
|
||||
else
|
||||
else
|
||||
bashio::exit.nok "OpenVPN configuration '/config/openvpn/${openvpn_config}' not found."
|
||||
fi
|
||||
fi
|
||||
|
||||
interface_name="$(sed -n "/^dev tun/p" "${openvpn_config}" | awk -F' ' '{print $2}')"
|
||||
|
||||
@@ -25,10 +25,9 @@ bashio::log.info "------------------------------"
|
||||
bashio::log.info "Wireguard enabled, configuring"
|
||||
bashio::log.info "------------------------------"
|
||||
|
||||
if bashio::config.has_value 'wireguard_config'; then
|
||||
wireguard_config="$(bashio::config 'wireguard_config')"
|
||||
wireguard_config="${wireguard_config##*/}"
|
||||
if [[ -z "${wireguard_config}" ]]; then
|
||||
wireguard_config="$(bashio::config 'wireguard_config')"
|
||||
wireguard_config="${wireguard_config##*/}"
|
||||
if [[ -z "${wireguard_config}" ]]; then
|
||||
bashio::log.info 'wireguard_config option left empty. Attempting automatic selection.'
|
||||
mapfile -t configs < <(find /config/wireguard -maxdepth 1 -type f -name '*.conf' -print)
|
||||
if [ "${#configs[@]}" -eq 0 ]; then
|
||||
@@ -42,11 +41,10 @@ if bashio::config.has_value 'wireguard_config'; then
|
||||
else
|
||||
bashio::exit.nok "Multiple WireGuard configuration files detected. Please set the 'wireguard_config' option."
|
||||
fi
|
||||
elif bashio::fs.file_exists "/config/wireguard/${wireguard_config}"; then
|
||||
elif bashio::fs.file_exists "/config/wireguard/${wireguard_config}"; then
|
||||
wireguard_config="/config/wireguard/${wireguard_config}"
|
||||
else
|
||||
else
|
||||
bashio::exit.nok "WireGuard configuration '/config/wireguard/${wireguard_config}' not found."
|
||||
fi
|
||||
fi
|
||||
|
||||
interface_name="$(basename "${wireguard_config}" .conf)"
|
||||
|
||||
Reference in New Issue
Block a user