From 5ce8b9d12793f5734bfe4edf1de47ee7ecfe3db6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 7 Jan 2022 07:22:22 +0100 Subject: [PATCH] Create 92-local_mounts.sh --- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 nextcloud/rootfs/etc/cont-init.d/92-local_mounts.sh diff --git a/nextcloud/rootfs/etc/cont-init.d/92-local_mounts.sh b/nextcloud/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi