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
|
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"]
|
||||||
@@ -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": [
|
||||||
|
|||||||
20
nfs/run.sh
20
nfs/run.sh
@@ -1,16 +1,23 @@
|
|||||||
#!/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")
|
if [ "${count}" -eq 0 ]; then
|
||||||
READ_ONLY=$(bashio::config "shares[${index}].read_only")
|
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}"
|
MOUNT_PATH="/${FOLDER}"
|
||||||
|
|
||||||
if bashio::var.true "${READ_ONLY}"; then
|
if [ "${READ_ONLY}" = "true" ]; then
|
||||||
OPTIONS="ro,no_root_squash"
|
OPTIONS="ro,no_root_squash"
|
||||||
else
|
else
|
||||||
OPTIONS="rw,no_root_squash"
|
OPTIONS="rw,no_root_squash"
|
||||||
@@ -18,7 +25,8 @@ for index in $(bashio::config 'shares|keys[]'); do
|
|||||||
|
|
||||||
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
|
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
cat /etc/exports
|
cat /etc/exports
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user