diff --git a/README.md b/README.md index bc34bf1..fe5d440 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ this package: * Integrate with YunoHost users and SSO - i.e. logout button * Allow one user to be the administrator (set at the installation) - * Optionally access the user home folder from Nextcloud files (set at the installation) + * Optionally access the user home folder from Nextcloud files (set at the + installation, the sharing is enabled by default) * Serve `/.well-known` paths for CalDAV and CardDAV on the domain only if it's not already served - i.e. by Baïkal diff --git a/scripts/_common.sh b/scripts/_common.sh index 9893a4d..e6f2758 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -72,6 +72,17 @@ exec_occ() { php occ --no-interaction --no-ansi "$@") } +# Create the external storage for the home folders and enable sharing +# usage: create_home_external_storage OCC_COMMAND +create_home_external_storage() { + local OCC=$1 + local mount_id=`$OCC files_external:create --output=json \ + 'Home' 'local' 'null::null' -c 'datadir=/home/$user' || true` + ! [[ $mount_id =~ ^[0-9]+$ ]] \ + && echo "Unable to create external storage" 1>&2 \ + || $OCC files_external:option "$mount_id" enable_sharing true +} + # Check if an URL is already handled # usage: is_url_handled URL is_url_handled() { diff --git a/scripts/install b/scripts/install index 035731f..d297a18 100755 --- a/scripts/install +++ b/scripts/install @@ -122,8 +122,7 @@ _exec_occ ldap:test-config \'\' \ # Enable External Storage and create local mount to home folder if [[ $user_home -eq 1 ]]; then _exec_occ app:enable files_external - _exec_occ files_external:create \ - 'Home' 'local' 'null::null' -c 'datadir=/home/$user' + create_home_external_storage '_exec_occ' fi # Add dynamic logout URL to the config diff --git a/scripts/upgrade b/scripts/upgrade index b08fcc6..a8e1afc 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -196,8 +196,7 @@ if [[ ${user_home} -eq 1 ]]; then _exec_occ app:enable files_external _exec_occ files_external:list --output=json \ | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ - || _exec_occ files_external:create \ - 'Home' 'local' 'null::null' -c 'datadir=/home/$user' + || create_home_external_storage '_exec_occ' fi # Add dynamic logout URL to the config