2019-03-17 20:41:07 +01:00
|
|
|
#!/usr/bin/with-contenv bashio
|
2019-02-13 16:54:02 +01:00
|
|
|
# ==============================================================================
|
|
|
|
# Community Hass.io Add-ons: ESPHome
|
|
|
|
# Configures NGINX for use with ESPHome
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
declare certfile
|
|
|
|
declare keyfile
|
2019-04-24 17:08:05 +02:00
|
|
|
declare direct_port
|
|
|
|
declare ingress_interface
|
|
|
|
declare ingress_port
|
2019-02-13 16:54:02 +01:00
|
|
|
|
|
|
|
mkdir -p /var/log/nginx
|
|
|
|
|
2019-04-24 17:08:05 +02:00
|
|
|
direct_port=$(bashio::addon.port 6052)
|
|
|
|
if bashio::var.has_value "${direct_port}"; then
|
|
|
|
if bashio::config.true 'ssl'; then
|
|
|
|
certfile=$(bashio::config 'certfile')
|
|
|
|
keyfile=$(bashio::config 'keyfile')
|
2019-02-13 16:54:02 +01:00
|
|
|
|
2019-04-24 17:08:05 +02:00
|
|
|
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
|
|
|
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf
|
|
|
|
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf
|
|
|
|
else
|
|
|
|
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
|
|
|
fi
|
2019-02-13 16:54:02 +01:00
|
|
|
|
2019-04-24 17:08:05 +02:00
|
|
|
sed -i "s/%%port%%/${direct_port}/g" /etc/nginx/servers/direct.conf
|
2019-02-13 16:54:02 +01:00
|
|
|
fi
|
|
|
|
|
2019-04-24 17:08:05 +02:00
|
|
|
ingress_port=$(bashio::addon.ingress_port)
|
|
|
|
ingress_interface=$(bashio::addon.ip_address)
|
|
|
|
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
|
|
|
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|