From f5b35ac52134839328deb279240f9771e9a13c5c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:50:08 +0200 Subject: [PATCH] Better test for mounts --- .templates/00-local_mounts.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.templates/00-local_mounts.sh b/.templates/00-local_mounts.sh index 942342e06..defe3a375 100755 --- a/.templates/00-local_mounts.sh +++ b/.templates/00-local_mounts.sh @@ -28,15 +28,20 @@ if bashio::config.has_value 'localdisks'; then # shellcheck disable=SC2086 for disk in ${MOREDISKS//,/ }; do - # Mount by device as default - devpath=/dev - - # Mount as uuid - if [ ${#disk} == 36 ] ; then + # Mount as uuid if length of name is 36 characters + if [ -e /dev/"${disk}" ] ; then + echo "... mount as uuid" devpath=/dev/disk/by-uuid - # Mount as label - elif [ "${disk:0:2}" != "sd" ] && [ "${disk:0:4}" != "nvme" ] ; then + # Mount as label if not found in /dev + elif [ -n "$(lsblk -o LABEL | grep -w "NAS" | awk '{print $1}')" ]; then + echo "... mount as label" devpath=/dev/disk/by-label + elif [ -e /dev/"${disk}" ] + echo "... mount as physical device" + devpath=/dev + else + bashio::log.fatal "... $disk was found neither in uuid, labels or physical drives, it will be skipped" + continue fi # Creates dir