From c94bc52dc2779f4c9ecbd961b0c9805b5011de62 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Tue, 27 Jun 2017 20:03:59 +0200 Subject: nc-automount fixes --- etc/nextcloudpi-config.d/nc-automount.sh | 16 +++++----------- etc/nextcloudpi-config.d/nc-backup.sh | 2 +- etc/nextcloudpi-config.d/nc-restore.sh | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/etc/nextcloudpi-config.d/nc-automount.sh b/etc/nextcloudpi-config.d/nc-automount.sh index 3e95db67..59c595a1 100644 --- a/etc/nextcloudpi-config.d/nc-automount.sh +++ b/etc/nextcloudpi-config.d/nc-automount.sh @@ -52,18 +52,11 @@ EOF cat > /usr/local/etc/blknum <<'EOF' #!/bin/bash -OUT=$( lsblk -l ) +# count all block devices with a file system, except /boot and /root. Start in 0 +NUM=$(( $( lsblk -l -n -o NAME,FSTYPE | grep -v mmcblk | awk '{ print $2 }' | sed '/^$/d' | wc -l ) - 1 )) -# partitions, from USB hard drives -PARTS=$( grep part <<< "$OUT" | wc -l ) - -# removable flash sticks -RM=$( awk '{ print $3 }' <<< "$OUT" | grep -c 1 ) - -# discount /boot and /root, start at 0 -RES=$(( RM + PARTS - 3 )) - -[[ $RES > 0 ]] && echo $RES || exit 0 +# first drive will be USBdrive, second USBdrive1 ... +[[ $NUM > 0 ]] && echo $NUM || exit 0 EOF chmod +x /usr/local/etc/blknum @@ -103,6 +96,7 @@ EOF [[ "$ACTIVE_" != "yes" ]] && rm -f /etc/udev/rules.d/50-automount.rules + # mount whatever is currently plugged in udevadm control --reload-rules && udevadm trigger } diff --git a/etc/nextcloudpi-config.d/nc-backup.sh b/etc/nextcloudpi-config.d/nc-backup.sh index b097c9c9..185b85c1 100644 --- a/etc/nextcloudpi-config.d/nc-backup.sh +++ b/etc/nextcloudpi-config.d/nc-backup.sh @@ -7,7 +7,7 @@ # # Usage: # -# ./installer.sh nc-backup () +# ./installer.sh nc-backup.sh () # # See installer.sh instructions for details # diff --git a/etc/nextcloudpi-config.d/nc-restore.sh b/etc/nextcloudpi-config.d/nc-restore.sh index 1d3d1b1b..8adea371 100644 --- a/etc/nextcloudpi-config.d/nc-restore.sh +++ b/etc/nextcloudpi-config.d/nc-restore.sh @@ -9,7 +9,7 @@ # # Usage: # -# ./installer.sh nc-restore () +# ./installer.sh nc-restore.sh () # # See installer.sh instructions for details # -- cgit v1.2.3