Home Assistant: prompt for bridge vs host networking

Let the user choose Home Assistant's networking mode at install time in the
-crowdsec variants:
- Bridge (default): publishes port 8123, works behind Caddy, isolated.
- Host: shares the host network for LAN device auto-discovery (Cast, HomeKit,
  mDNS/Zeroconf, some Zigbee/Z-Wave/Bluetooth).

The compose file is generated conditionally; both modes verified to produce
valid YAML, and both scripts pass 'bash -n' and a --dry-run --unattended pass.

https://claude.ai/code/session_017eA2qqq9jfF2tNtpUYL8vK
This commit is contained in:
Claude
2026-06-03 12:25:15 +00:00
parent 8f6523a47b
commit d528cfbea3
3 changed files with 44 additions and 9 deletions
+4 -1
View File
@@ -17,7 +17,10 @@ complete, standalone script).
> historical snapshots. For example, **Home Assistant** (home-automation hub,
> port 8123) is available in the `-crowdsec` variants. It ships with a
> `trusted_proxies` config pre-seeded so it works behind the Caddy reverse
> proxy out of the box.
> proxy out of the box, and the installer asks whether to use **bridge**
> networking (port 8123 published — proxy-friendly, isolated) or **host**
> networking (needed for LAN device auto-discovery: Chromecast, HomeKit,
> mDNS, some Zigbee/Z-Wave/Bluetooth).
## Which one?
+20 -4
View File
@@ -4974,6 +4974,25 @@ MEALIE_COMPOSE
ensure_docker_dir_ownership "$HOMEASSISTANT_DIR"
cd "$HOMEASSISTANT_DIR"
# Networking mode: bridge (published port) vs host networking.
echo ""
echo " Home Assistant networking mode:"
echo " 1) Bridge - container gets its own network; port 8123 is published"
echo " to the host. Works behind the Caddy reverse proxy and"
echo " keeps HA isolated. Recommended for most setups."
echo " 2) Host - HA shares the host's network directly. Needed for"
echo " auto-discovery of devices on your LAN (Chromecast/Cast,"
echo " HomeKit, mDNS/Zeroconf, some Zigbee/Z-Wave & Bluetooth)."
prompt_text " Choose networking mode [1]:" "1" HA_NETMODE
if [ "$HA_NETMODE" = "2" ]; then
HA_NET_LINES=" network_mode: host"
echo " → Host networking selected (best device discovery)."
else
HA_NET_LINES=" ports:
- \"8123:8123\""
echo " → Bridge networking selected (port 8123 published)."
fi
cat > docker-compose.yml << HOMEASSISTANT_COMPOSE
name: homeassistant
@@ -4989,10 +5008,7 @@ services:
volumes:
- ./config:/config
- /run/dbus:/run/dbus:ro
ports:
- "8123:8123"
# For full device/mDNS auto-discovery (Zigbee/Z-Wave/Bluetooth/Cast),
# remove the 'ports:' block above and add: network_mode: host
${HA_NET_LINES}
HOMEASSISTANT_COMPOSE
mkdir -p config
+20 -4
View File
@@ -4954,6 +4954,25 @@ MEALIE_COMPOSE
ensure_docker_dir_ownership "$HOMEASSISTANT_DIR"
cd "$HOMEASSISTANT_DIR"
# Networking mode: bridge (published port) vs host networking.
echo ""
echo " Home Assistant networking mode:"
echo " 1) Bridge - container gets its own network; port 8123 is published"
echo " to the host. Works behind the Caddy reverse proxy and"
echo " keeps HA isolated. Recommended for most setups."
echo " 2) Host - HA shares the host's network directly. Needed for"
echo " auto-discovery of devices on your LAN (Chromecast/Cast,"
echo " HomeKit, mDNS/Zeroconf, some Zigbee/Z-Wave & Bluetooth)."
prompt_text " Choose networking mode [1]:" "1" HA_NETMODE
if [ "$HA_NETMODE" = "2" ]; then
HA_NET_LINES=" network_mode: host"
echo " → Host networking selected (best device discovery)."
else
HA_NET_LINES=" ports:
- \"8123:8123\""
echo " → Bridge networking selected (port 8123 published)."
fi
cat > docker-compose.yml << HOMEASSISTANT_COMPOSE
name: homeassistant
@@ -4969,10 +4988,7 @@ services:
volumes:
- ./config:/config
- /run/dbus:/run/dbus:ro
ports:
- "8123:8123"
# For full device/mDNS auto-discovery (Zigbee/Z-Wave/Bluetooth/Cast),
# remove the 'ports:' block above and add: network_mode: host
${HA_NET_LINES}
HOMEASSISTANT_COMPOSE
mkdir -p config