fix(nfs): read config from /data/options.json with jq, bypass Supervisor API
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
RUN apk add --no-cache unfs3 bash
|
||||
RUN apk add --no-cache unfs3 bash jq
|
||||
COPY run.sh /
|
||||
RUN chmod +x /run.sh
|
||||
CMD ["/run.sh"]
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "NFS Server",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"slug": "nfs_server",
|
||||
"description": "Expose Home Assistant media folder via NFS.",
|
||||
"arch": [
|
||||
|
||||
18
nfs/run.sh
18
nfs/run.sh
@@ -1,16 +1,23 @@
|
||||
#!/usr/bin/env bashio
|
||||
|
||||
CONFIG="/data/options.json"
|
||||
|
||||
# Build /etc/exports from configured shares
|
||||
bashio::log.info "Configuring NFS exports..."
|
||||
> /etc/exports
|
||||
|
||||
for index in $(bashio::config 'shares|keys[]'); do
|
||||
FOLDER=$(bashio::config "shares[${index}].folder")
|
||||
NETWORK=$(bashio::config "shares[${index}].allowed_network")
|
||||
READ_ONLY=$(bashio::config "shares[${index}].read_only")
|
||||
count=$(jq '.shares | length' "${CONFIG}")
|
||||
|
||||
if [ "${count}" -eq 0 ]; then
|
||||
bashio::log.warning "No shares configured, nothing to export."
|
||||
else
|
||||
for i in $(seq 0 $((count - 1))); do
|
||||
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}"
|
||||
|
||||
if bashio::var.true "${READ_ONLY}"; then
|
||||
if [ "${READ_ONLY}" = "true" ]; then
|
||||
OPTIONS="ro,no_root_squash"
|
||||
else
|
||||
OPTIONS="rw,no_root_squash"
|
||||
@@ -19,6 +26,7 @@ for index in $(bashio::config 'shares|keys[]'); do
|
||||
bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..."
|
||||
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports
|
||||
done
|
||||
fi
|
||||
|
||||
cat /etc/exports
|
||||
|
||||
|
||||
Reference in New Issue
Block a user