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

github.com/nextcloud/vm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorszaimen <szaimen@e.mail.de>2021-02-26 01:21:37 +0300
committerGitHub <noreply@github.com>2021-02-26 01:21:37 +0300
commita3b9a6fe8daaecd028466880ee4fe9c51ba69e82 (patch)
tree9a1bd3700945203f89cb77ece2ec28806312d152 /not-supported
parent360d4802fa032c424f2bc47e3bfd4ad08bc3382d (diff)
smbserver - completely rework how directories get mounted to Nextcloud (#1857)
Signed-off-by: szaimen <szaimen@e.mail.de>
Diffstat (limited to 'not-supported')
-rw-r--r--not-supported/smbserver.sh96
1 files changed, 37 insertions, 59 deletions
diff --git a/not-supported/smbserver.sh b/not-supported/smbserver.sh
index 3e75d029..7f5a2909 100644
--- a/not-supported/smbserver.sh
+++ b/not-supported/smbserver.sh
@@ -754,36 +754,13 @@ you can also connect using the IP-address: '$ADDRESS' instead of nextcloud." "$S
install_and_enable_app files_external
fi
- # Safe NEWNAME in a backup variable
- NEWNAME_BACKUP="$NEWNAME"
-
- # Ask if the default name can be used
- if yesno_box_no "Do you want to use a different name for this external storage inside Nextcloud or \
-just use the default sharename $NEWNAME?\nThis time spaces are possible." "$SUBTITLE"
+ # Mount directory as root directory if only one user was chosen
+ if [ "${#VALID_USERS_AR[*]}" -eq 1 ] && [ "$WRITEABLE" = "yes" ]
then
- while :
- do
- # Type in the new mountname that will be used in NC
- NEWNAME=$(input_box_flow "Please enter the name that will be used inside Nextcloud for this path $NEWPATH.
-You can type in 'exit' and press [ENTER] to use the default $NEWNAME_BACKUP
-Allowed characters are only spaces, those four special characters '.-_/' and 'a-z' 'A-Z' '0-9'.
-Also, it has to start with a slash '/' or a letter 'a-z' or 'A-Z' to be valid.
-Advice: you can declare a directory as the Nextcloud users root storage by naming it '/'." "$SUBTITLE")
- if ! echo "$NEWNAME" | grep -q "^[a-zA-Z/]"
- then
- msg_box "The name has to start with a slash '/' or a letter 'a-z' or 'A-Z' to be valid." "$SUBTITLE"
- elif ! [[ "$NEWNAME" =~ ^[-._a-zA-Z0-9\ /]+$ ]]
- then
- msg_box "Allowed characters are only spaces, those \
-four special characters '.-_/' and 'a-z' 'A-Z' '0-9'." "$SUBTITLE"
- elif [ "$NEWNAME" = "exit" ]
- then
- NEWNAME="$NEWNAME_BACKUP"
- break
- else
- break
- fi
- done
+ if yesno_box_yes "Do you want to make $NEWPATH the root folder for ${VALID_USERS_AR[*]}?"
+ then
+ NEWNAME="/"
+ fi
fi
# Choose if it shall be writeable in NC
@@ -795,29 +772,27 @@ four special characters '.-_/' and 'a-z' 'A-Z' '0-9'." "$SUBTITLE"
READONLY="true"
fi
- # Choose if sharing shall get enabled for that mount
- if [ "$NEWNAME" = "/" ]
+ # Find other attributes
+ SHARING="true"
+ SELECTED_USER=""
+ UNAVAILABLE_USER=""
+ # Choose from NC users
+ NC_USER=$(nextcloud_occ_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||')
+ for user in "${VALID_USERS_AR[@]}"
+ do
+ if echo "$NC_USER" | grep -q "^$user$"
+ then
+ SELECTED_USER+="$user "
+ else
+ UNAVAILABLE_USER+="$user "
+ fi
+ done
+ if [ -n "$UNAVAILABLE_USER" ]
then
- SHARING="false"
- SELECTED_USER=""
- else
- SHARING="true"
- SELECTED_USER=""
- UNAVAILABLE_USER=""
- # Choose from NC users
- NC_USER=$(nextcloud_occ_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||')
- for user in "${VALID_USERS_AR[@]}"
- do
- if echo "$NC_USER" | grep -q "^$user$"
- then
- SELECTED_USER+="$user "
- else
- UNAVAILABLE_USER+="$user "
- fi
- done
- if [ -n "$UNAVAILABLE_USER" ]
+ msg_box "Some chosen SMB-users weren't available in Nextcloud:\n$UNAVAILABLE_USER"
+ if ! yesno_box_no "Do you want to continue nonetheless?"
then
- msg_box "Some chosen SMB-users weren't available in Nextcloud: $UNAVAILABLE_USER"
+ return
fi
fi
@@ -827,15 +802,18 @@ four special characters '.-_/' and 'a-z' 'A-Z' '0-9'." "$SUBTITLE"
MOUNT_ID=${MOUNT_ID//[!0-9]/}
# Mount it to the admin group if no group or user chosen
- if [ -z "$SELECTED_USER" ] && [ "$NEWNAME" != "/" ]
- then
- msg_box "No SMB-user available in Nextcloud, mounting the local storage to the admin group."
- nextcloud_occ files_external:applicable --add-group=admin "$MOUNT_ID" -q
- fi
-
- # Mount it to selected users
- if [ -n "$SELECTED_USER" ]
+ if [ -z "$SELECTED_USER" ]
then
+ if [ "$NEWNAME" != "/" ]
+ then
+ nextcloud_occ files_external:applicable --add-group=admin "$MOUNT_ID" -q
+ msg_box "No SMB-user available in Nextcloud, mounted the local storage to the admin group."
+ else
+ nextcloud_occ files_external:delete "$MOUNT_ID" -y
+ msg_box "No SMB-user available in Nextcloud, could not add the storage to Nextcloud!"
+ return
+ fi
+ else
nextcloud_occ_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||' | while read -r NC_USER
do
if [[ "$SELECTED_USER" = *"$NC_USER "* ]]
@@ -851,7 +829,7 @@ four special characters '.-_/' and 'a-z' 'A-Z' '0-9'." "$SUBTITLE"
nextcloud_occ files_external:option "$MOUNT_ID" enable_sharing "$SHARING"
# Inform the user that mounting was successful
- msg_box "Your mount $NEWNAME was successful, congratulations!
+ msg_box "Your mount was successful, congratulations!
You are now using the Nextcloud external storage app to access files there.
The Share has been mounted to the Nextcloud admin-group if not specifically changed to users or groups.
You can now access 'https://yourdomain-or-ipaddress/settings/admin/externalstorages' \