From 8d6a3680452854486421967a62e6e1d6242a233d Mon Sep 17 00:00:00 2001 From: oliwoli Date: Wed, 19 Feb 2025 16:04:22 +0100 Subject: [PATCH] mount directories via conf file --- bind_mounts.conf | 24 ++++++++++++++++++++++++ env-set.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 bind_mounts.conf diff --git a/bind_mounts.conf b/bind_mounts.conf new file mode 100644 index 0000000..0a6fe09 --- /dev/null +++ b/bind_mounts.conf @@ -0,0 +1,24 @@ +# DaVinci Resolve Bind Mounts Configuration +# +# Define which host folders will be accessible inside the Resolve container. +# +# USAGE: +# 1. Set TARGET to the desired mount point inside the container. +# 2. List absolute or home (~) paths below it. +# 3. Uncomment and edit as needed. + +# Default mount point (do not change) +TARGET=/opt/resolve/Media + +# === ADD YOUR MEDIA FOLDERS BELOW === +#/home/user/Videos + + +# === CUSTOM MOUNT POINTS === +# To mount elsewhere, define a new TARGET: +#TARGET=/mnt/CustomFolder +#/mnt/ExternalDrive/Project + +# After adding new paths: +# - Restart the container +# - In Resolve: Preferences > Media Storage > Add diff --git a/env-set.sh b/env-set.sh index c0cadf6..4c91270 100644 --- a/env-set.sh +++ b/env-set.sh @@ -41,6 +41,54 @@ else echo "The container's bind-mounts path (RESOLVE_MOUNTS_PATH) was manually set to : ${RESOLVE_MOUNTS_PATH}" fi +# Read custom bind mounts from configuration file +if [ -f "${BASH_SOURCE%/*}/bind_mounts.conf" ]; then + echo "Reading bind mounts from bind_mounts.conf..." + while IFS= read -r source || [ -n "$source" ]; do + # Skip empty lines + [ -z "$source" ] && continue + + # Skip comment lines (lines starting with #) + [ "${source:0:1}" = "#" ] && continue + + # Check if the line defines a TARGET + if [[ "$source" =~ ^TARGET=.* ]]; then + TARGET="${source#TARGET=}" + echo "Setting target path within container to: $TARGET" + continue + fi + + # Trim whitespace from source path + source="${source#"${source%%[![:space:]]*}"}" + source="${source%"${source##*[![:space:]]}"}" + + # Replace ~ with the home directory + source="${source//\~/$HOME}" + + if [ ! -e "$source" ]; then + echo "Warning: Bind mount source path does not exist: $source" + continue + fi + + if [ ! -r "$source" ]; then + echo "Warning: Bind mount source path is not readable: $source" + continue + fi + + # Create a sanitized target name from the source path's basename + target_name=$(basename "$source" | tr ' ' '_') + + if [ -z "$TARGET" ]; then + TARGET="/opt/resolve/Media" + fi + + target="${TARGET}/${target_name}" + RESOLVE_BIND_SOURCES+=("$source") + RESOLVE_BIND_TARGETS+=("$target") + echo "Added bind mount: $source -> $target" + done <"${BASH_SOURCE%/*}/bind_mounts.conf" +fi + # and notify if other tags were overridden if [ ! -z ${RESOLVE_TAG} ]; then @@ -50,4 +98,3 @@ fi if [ ! -z ${RESOLVE_ZIP} ]; then echo "The Resolve zip file location (RESOLVE_ZIP) was manually set to : ${RESOLVE_ZIP}" fi -