fix(nfs): support comma-separated networks in allowed_network field

This commit is contained in:
2026-03-31 12:10:00 +02:00
parent 77a3fea2d6
commit 3123d313c1
3 changed files with 90 additions and 14 deletions

View File

@@ -1,24 +1,94 @@
# Home Assistant Add-on: NFS Server # Home Assistant Add-on: NFS Server
This add-on exposes the Home Assistant media folder via NFS. ![Supports amd64 Architecture][amd64-shield]
![Supports aarch64 Architecture][aarch64-shield]
![Supports armv7 Architecture][armv7-shield]
This add-on provides a **user-space NFS server** based on unfs3, perfect for:
- Mounting Home Assistant folders on other machines on your network
- Sharing media, config, or backup folders over NFS
It is designed to be **lightweight and kernel-independent**, running entirely in user-space without requiring NFS kernel modules.
## Configuration ## Configuration
The following configuration options are available: ```yaml
shares:
- folder: media
allowed_network: 192.168.1.0/24
read_only: false
```
- `allowed_network`: The network allowed to access the NFS share (e.g., `192.168.1.0/24`). Defaults to `0.0.0.0/0` (everyone). It is highly recommended to restrict this to your local network. ### Parameters
## How to use | Variable | Default | Description |
|-----------------------------|---------------------|--------------------------------------------------------------------|
| `shares[].folder` | `media` | HA folder to export (`media`, `share`, `config`, `backup`) |
| `shares[].allowed_network` | `192.168.1.0/24` | Network(s) allowed to access the share. Comma-separated for multiple (e.g. `192.168.1.0/24, 10.0.0.0/8`) |
| `shares[].read_only` | `false` | Whether the share is read-only |
1. Start the add-on. You can define multiple shares:
2. On your client machine, mount the NFS share. The NFS share will be the IP of your Home Assistant instance, and the exported path is `/media`.
Example on a Linux client: ```yaml
```bash shares:
mkdir /mnt/hass-media - folder: media
mount -t nfs <home-assistant-ip>:/media /mnt/hass-media allowed_network: 192.168.1.0/24
``` read_only: false
- folder: share
allowed_network: 192.168.1.0/24
read_only: false
- folder: config
allowed_network: 192.168.1.10/32
read_only: true
```
## Installation
1. Go to Home Assistant → **Supervisor → Add-on Store**
2. Add this repository (Settings → Repositories → `https://github.com/martemme/HomeAssistantAddons`)
3. Install the add-on, configure your shares and start it
## Usage
Once started, mount a share from a client machine.
Example on Linux:
```bash
mkdir /mnt/hass-media
mount -t nfs <home-assistant-ip>:/media /mnt/hass-media
```
Example on macOS:
```bash
mkdir /mnt/hass-media
mount -t nfs -o resvport <home-assistant-ip>:/media /mnt/hass-media
```
## Requirements
- Home Assistant OS or Supervised
- Supported architecture: `amd64`, `aarch64`, `armv7`
- NFS kernel modules are **not** required (uses unfs3 user-space server)
## Notes ## Notes
This addon requires `host_network` and `SYS_ADMIN` privileges to run. > ⚠️ Always restrict `allowed_network` to your local subnet. Avoid using `0.0.0.0/0` in production.
## Changelog & Releases
Releases are based on [Semantic Versioning][semver], and use the format
of `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented
based on the following:
- `MAJOR`: Incompatible or major changes.
- `MINOR`: Backwards-compatible new features and enhancements.
- `PATCH`: Backwards-compatible bugfixes and package updates.
---
Made with ❤️ for automation and resilience.
[semver]: http://semver.org/spec/v2.0.0.html
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg

View File

@@ -1,6 +1,6 @@
{ {
"name": "NFS Server", "name": "NFS Server",
"version": "1.0.6", "version": "1.0.7",
"slug": "nfs_server", "slug": "nfs_server",
"description": "Expose Home Assistant media folder via NFS.", "description": "Expose Home Assistant media folder via NFS.",
"arch": [ "arch": [

View File

@@ -24,7 +24,13 @@ else
fi fi
bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..." bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..."
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports EXPORT_LINE="${MOUNT_PATH}"
IFS=',' read -ra NETWORKS <<< "${NETWORK}"
for net in "${NETWORKS[@]}"; do
net=$(echo "${net}" | tr -d ' ')
EXPORT_LINE="${EXPORT_LINE} ${net}(${OPTIONS})"
done
echo "${EXPORT_LINE}" >> /etc/exports
done done
fi fi