diff --git a/netbird-server/DOCS.md b/netbird-server/DOCS.md index e6caa470b..556fecf6f 100644 --- a/netbird-server/DOCS.md +++ b/netbird-server/DOCS.md @@ -16,7 +16,7 @@ NetBird relies on gRPC. The built-in Caddy configuration is pre-wired to proxy b This add-on generates the standard quickstart configuration files in `/config/netbird` and reuses them on subsequent starts. ### Required options -- `domain`: Public domain that resolves to your Home Assistant host (e.g., `netbird.example.com`). +- `domain`: Public domain that resolves to your Home Assistant host (e.g., `netbird.example.com`). If left at the default placeholder, the add-on will try to use the host from Home Assistant's `external_url` or `internal_url` instead. ### Dashboard environment overrides Edit `/config/netbird/dashboard/env` to configure the dashboard UI: diff --git a/netbird-server/rootfs/etc/cont-init.d/00-config.sh b/netbird-server/rootfs/etc/cont-init.d/00-config.sh index a31c7008f..c233205ae 100755 --- a/netbird-server/rootfs/etc/cont-init.d/00-config.sh +++ b/netbird-server/rootfs/etc/cont-init.d/00-config.sh @@ -33,8 +33,20 @@ SIGNAL_GRPC_PORT=10000 RELAY_PORT=8084 if [[ -z "$DOMAIN" || "$DOMAIN" == "netbird.example.com" ]]; then - bashio::log.error "Set a valid domain in the add-on configuration (domain cannot be empty or netbird.example.com)." - bashio::exit.nok + result=$(bashio::api.supervisor GET /core/api/config true || true) + external_host="$(bashio::jq "$result" '.external_url' | cut -d'/' -f3 | cut -d':' -f1)" + internal_host="$(bashio::jq "$result" '.internal_url' | cut -d'/' -f3 | cut -d':' -f1)" + + if [[ -n "$external_host" && "$external_host" != "null" ]]; then + DOMAIN="$external_host" + bashio::log.warning "Domain not set; using Home Assistant external_url host: ${DOMAIN}" + elif [[ -n "$internal_host" && "$internal_host" != "null" ]]; then + DOMAIN="$internal_host" + bashio::log.warning "Domain not set; using Home Assistant internal_url host: ${DOMAIN}" + else + bashio::log.error "Set a valid domain in the add-on configuration (domain cannot be empty or netbird.example.com)." + bashio::exit.nok + fi fi NETBIRD_PORT=443