fix(nfs): read config from /data/options.json with jq, bypass Supervisor API

This commit is contained in:
2026-03-31 12:07:50 +02:00
parent 8d5668252f
commit 77a3fea2d6
3 changed files with 23 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
ARG BUILD_FROM ARG BUILD_FROM
FROM $BUILD_FROM FROM $BUILD_FROM
RUN apk add --no-cache unfs3 bash RUN apk add --no-cache unfs3 bash jq
COPY run.sh / COPY run.sh /
RUN chmod +x /run.sh RUN chmod +x /run.sh
CMD ["/run.sh"] CMD ["/run.sh"]

View File

@@ -1,6 +1,6 @@
{ {
"name": "NFS Server", "name": "NFS Server",
"version": "1.0.5", "version": "1.0.6",
"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

@@ -1,24 +1,32 @@
#!/usr/bin/env bashio #!/usr/bin/env bashio
CONFIG="/data/options.json"
# Build /etc/exports from configured shares # Build /etc/exports from configured shares
bashio::log.info "Configuring NFS exports..." bashio::log.info "Configuring NFS exports..."
> /etc/exports > /etc/exports
for index in $(bashio::config 'shares|keys[]'); do count=$(jq '.shares | length' "${CONFIG}")
FOLDER=$(bashio::config "shares[${index}].folder")
NETWORK=$(bashio::config "shares[${index}].allowed_network")
READ_ONLY=$(bashio::config "shares[${index}].read_only")
MOUNT_PATH="/${FOLDER}"
if bashio::var.true "${READ_ONLY}"; then if [ "${count}" -eq 0 ]; then
OPTIONS="ro,no_root_squash" bashio::log.warning "No shares configured, nothing to export."
else else
OPTIONS="rw,no_root_squash" for i in $(seq 0 $((count - 1))); do
fi FOLDER=$(jq -r ".shares[${i}].folder" "${CONFIG}")
NETWORK=$(jq -r ".shares[${i}].allowed_network" "${CONFIG}")
READ_ONLY=$(jq -r ".shares[${i}].read_only" "${CONFIG}")
MOUNT_PATH="/${FOLDER}"
bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..." if [ "${READ_ONLY}" = "true" ]; then
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports OPTIONS="ro,no_root_squash"
done else
OPTIONS="rw,no_root_squash"
fi
bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..."
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports
done
fi
cat /etc/exports cat /etc/exports