fix(nfs): read config from /data/options.json with jq, bypass Supervisor API
This commit is contained in:
34
nfs/run.sh
34
nfs/run.sh
@@ -1,24 +1,32 @@
|
||||
#!/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")
|
||||
MOUNT_PATH="/${FOLDER}"
|
||||
count=$(jq '.shares | length' "${CONFIG}")
|
||||
|
||||
if bashio::var.true "${READ_ONLY}"; then
|
||||
OPTIONS="ro,no_root_squash"
|
||||
else
|
||||
OPTIONS="rw,no_root_squash"
|
||||
fi
|
||||
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}"
|
||||
|
||||
bashio::log.info "Exporting ${MOUNT_PATH} to ${NETWORK} (${OPTIONS})..."
|
||||
echo "${MOUNT_PATH} ${NETWORK}(${OPTIONS})" >> /etc/exports
|
||||
done
|
||||
if [ "${READ_ONLY}" = "true" ]; then
|
||||
OPTIONS="ro,no_root_squash"
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user