Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2017-08-15 18:26:27 +0300
committernachoparker <nacho@ownyourbits.com>2017-08-15 18:29:03 +0300
commit96685c2928597c5b0499ac782644581fc5903abf (patch)
treee7070a89b6b569ed12da14ff9be393166ec02fa8
parent9176473b2df5dc892afc31159380f51e8d239c8f (diff)
nc-automount: fixed persistence of links and morev0.20.3
-rw-r--r--etc/nextcloudpi-config.d/nc-automount.sh19
-rwxr-xr-xupdate.sh24
2 files changed, 35 insertions, 8 deletions
diff --git a/etc/nextcloudpi-config.d/nc-automount.sh b/etc/nextcloudpi-config.d/nc-automount.sh
index c4108c47..fbebea7d 100644
--- a/etc/nextcloudpi-config.d/nc-automount.sh
+++ b/etc/nextcloudpi-config.d/nc-automount.sh
@@ -52,16 +52,22 @@ EOF
cat > /usr/local/etc/blknum <<'EOF'
#!/bin/bash
-test -e /dev/USBdrive || exit 0
+# we perform a cleanup with the first one
+ls -d /dev/USBdrive* &>/dev/null || {
+ rmdir /media/USBdrive*
+ for f in `ls /media/`; do
+ test -L $f && rm $f
+ done
+ exit 0
+}
for i in `seq 1 1 8`; do
- test -e /dev/USBdrive$i && continue
+ test -e /media/USBdrive$i && continue
echo $i
exit 0
done
exit 1
-
EOF
chmod +x /usr/local/etc/blknum
@@ -74,7 +80,7 @@ configure()
{
cat > /etc/udev/rules.d/50-automount.rules <<'EOF'
# Need to be a block device
-KERNEL!="sd[a-z]*", GOTO="exit"
+KERNEL!="sd[a-z][0-9]", GOTO="exit"
# Import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
@@ -89,10 +95,7 @@ ACTION!="remove", PROGRAM="/usr/local/etc/blknum", RUN+="/bin/mkdir -p /media/US
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
# Link with label name if exists
-ACTION!="remove", ENV{ID_FS_LABEL}!="", ENV{ID_FS_LABEL}!="USBdrive*", RUN+="/bin/ln -sT /media/USBdrive%c /media/%E{ID_FS_LABEL}"
-
-# Cleanup created link
-ACTION=="remove", ENV{ID_FS_LABEL}, ENV{ID_FS_LABEL}!="USBdrive*"!="", RUN+="/bin/rm /media/%E{ID_FS_LABEL}"
+ACTION=="add", ENV{ID_FS_LABEL}!="", ENV{ID_FS_LABEL}!="USBdrive*", RUN+="/bin/rm /media/%E{ID_FS_LABEL}", RUN+="/bin/ln -sT /media/USBdrive%c /media/%E{ID_FS_LABEL}"
# Exit
LABEL="exit"
diff --git a/update.sh b/update.sh
index a49d3fd6..a521fd5f 100755
--- a/update.sh
+++ b/update.sh
@@ -63,6 +63,30 @@ test -f /root/.my.cnf || echo -e "[client]\npassword=ownyourbits" > /root/.my.cn
chown www-data /var/www/nextcloud/.htaccess
rm -rf /var/www/nextcloud/.well-known
+# fix automount
+cat > /usr/local/etc/blknum <<'EOF'
+#!/bin/bash
+
+# we perform a cleanup with the first one
+ls -d /dev/USBdrive* &>/dev/null || {
+ rmdir /media/USBdrive*
+ for f in `ls /media/`; do
+ test -L $f && rm $f
+ done
+ exit 0
+}
+
+for i in `seq 1 1 8`; do
+ test -e /media/USBdrive$i && continue
+ echo $i
+ exit 0
+done
+
+exit 1
+EOF
+ chmod +x /usr/local/etc/blknum
+
+
# License
#
# This script is free software; you can redistribute it and/or modify it