home-assistant-addon/esphome-dev/rootfs/etc/cont-init.d/20-nginx.sh

27 lines
771 B
Bash
Raw Normal View History

2019-03-17 20:07:36 +01:00
#!/usr/bin/with-contenv bashio
2019-02-13 22:05:11 +01:00
# ==============================================================================
# Community Hass.io Add-ons: ESPHome
# Configures NGINX for use with ESPHome
# ==============================================================================
declare certfile
declare keyfile
declare port
mkdir -p /var/log/nginx
# Enable SSL
2019-03-17 20:07:36 +01:00
if bashio::config.true 'ssl'; then
2019-02-13 22:05:11 +01:00
rm /etc/nginx/nginx.conf
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
2019-03-17 20:07:36 +01:00
certfile=$(bashio::config 'certfile')
keyfile=$(bashio::config 'keyfile')
2019-02-13 22:05:11 +01:00
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
fi
2019-03-17 20:07:36 +01:00
port=$(bashio::config 'port')
2019-02-13 22:05:11 +01:00
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf