home-assistant-addon/esphome-dev/rootfs/etc/cont-init.d/10-requirements.sh

42 lines
1.7 KiB
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
# This files check if all user configuration requirements are met
# ==============================================================================
# Check SSL requirements, if enabled
2019-03-17 20:07:36 +01:00
if bashio::config.true 'ssl'; then
if ! bashio::config.has_value 'certfile'; then
bashio::fatal 'SSL is enabled, but no certfile was specified.'
bashio::exit.nok
2019-02-13 22:05:11 +01:00
fi
2019-03-17 20:07:36 +01:00
if ! bashio::config.has_value 'keyfile'; then
bashio::fatal 'SSL is enabled, but no keyfile was specified'
bashio::exit.nok
2019-02-13 22:05:11 +01:00
fi
2019-03-17 20:07:36 +01:00
certfile="/ssl/$(bashio::config 'certfile')"
keyfile="/ssl/$(bashio::config 'keyfile')"
if ! bashio::fs.file_exists "${certfile}"; then
if ! bashio::fs.file_exists "${keyfile}"; then
2019-02-13 22:05:11 +01:00
# Both files are missing, let's print a friendlier error message
2019-03-17 20:07:36 +01:00
bashio::log.fatal 'You enabled encrypted connections using the "ssl": true option.'
bashio::log.fatal "However, the SSL files '${certfile}' and '${keyfile}'"
bashio::log.fatal "were not found. If you're using Hass.io on your local network and don't want"
bashio::log.fatal 'to encrypt connections to the ESPHome dashboard, you can manually disable'
bashio::log.fatal 'SSL by setting "ssl" to false."'
bashio::exit.nok
2019-02-13 22:05:11 +01:00
fi
2019-03-17 20:07:36 +01:00
bashio::log.fatal "The configured certfile '${certfile}' was not found."
bashio::exit.nok
2019-02-13 22:05:11 +01:00
fi
2019-03-17 20:07:36 +01:00
if ! bashio::fs.file_exists "/ssl/$(bashio::config 'keyfile')"; then
bashio::log.fatal "The configured keyfile '${keyfile}' was not found."
bashio::exit.nok
2019-02-13 22:05:11 +01:00
fi
fi