setup-opds.sh: replace hardcoded books path with dynamic spoke mount listing

This commit is contained in:
Justin Oros
2026-04-20 16:08:31 -07:00
parent 4586a0f598
commit 21a1c7e922

View File

@@ -93,8 +93,42 @@ read -rp "Hub user [armbian]: " HUB_USER
HUB_USER="${HUB_USER:-armbian}"
HUB_HOME="/home/$HUB_USER"
read -rp "Path to books directory [${HUB_HOME}/mnt/grace/st/data/books/justin]: " BOOKS_PATH
BOOKS_PATH="${BOOKS_PATH:-${HUB_HOME}/mnt/grace/st/data/books/justin}"
MOUNT_BASE="${HUB_HOME}/mnt"
AVAILABLE_MOUNTS=()
if [ -d "$MOUNT_BASE" ]; then
while IFS= read -r mountdir; do
AVAILABLE_MOUNTS+=("$mountdir")
done < <(find "$MOUNT_BASE" -mindepth 1 -maxdepth 1 -type d | sort)
fi
if [ ${#AVAILABLE_MOUNTS[@]} -gt 0 ]; then
echo "Available spoke mounts:"
for i in "${!AVAILABLE_MOUNTS[@]}"; do
echo " $i) ${AVAILABLE_MOUNTS[$i]}"
done
echo " m) Enter path manually"
echo ""
read -rp "Choose a mount [0]: " MOUNT_CHOICE
MOUNT_CHOICE="${MOUNT_CHOICE:-0}"
if [[ "$MOUNT_CHOICE" == "m" ]]; then
read -rp "Path to books directory: " BOOKS_PATH
elif [[ "$MOUNT_CHOICE" =~ ^[0-9]+$ ]] && [ "$MOUNT_CHOICE" -lt "${#AVAILABLE_MOUNTS[@]}" ]; then
BASE="${AVAILABLE_MOUNTS[$MOUNT_CHOICE]}"
read -rp "Subdirectory within ${BASE} (leave blank for root): " SUBDIR
if [ -n "$SUBDIR" ]; then
BOOKS_PATH="${BASE}/${SUBDIR}"
else
BOOKS_PATH="$BASE"
fi
else
die "Invalid choice."
fi
else
warn "No spoke mounts found in ${MOUNT_BASE}."
read -rp "Path to books directory: " BOOKS_PATH
fi
[ -n "$BOOKS_PATH" ] || die "Books path cannot be empty."
[ -d "$BOOKS_PATH" ] || die "Books directory not found: $BOOKS_PATH"
echo ""