Cool Solution - Mount Samba shares in Nextcloud
From Univention Wiki
Nextcloud is a free and open source file hosting service and available in the Univention App Center to easily install it on UCS. Nextcloud is capable of mounting external storages from different backends, including Samba shares. A few packages made by Univention enable you to automatically mount your UCS@school shares such as class or workgroup shares. To install these, the Cool Solutions Repository must be enabled.
Enabling Nextcloud for users and groups
Nextcloud access can be enabled manually via the web interface UMC using the Users or Groups module. In the Users module, open a specific user, switch to Advanced settings and tick the checkbox in the Nextcloud dropdown. In the Groups module, open a specific group, switch to Nextcloud and tick the checkbox. After Nextcloud is installed, newly created users are automatically enabled in Nextcloud.
The package univention-nextcloud-enable-for-classes-and-workgroups from the Cool Solutions Repository enables all classes, workgroups and Domain Users <OU> groups for Nextcloud. This is required for the groups to show up in Nextcloud and be used there to limit access to shares to their respective groups. The package must be installed on the domaincontroller master of your domain!
To mount Samba shares in Nextcloud the files_external Nextcloud app must be enabled. To enable the app, login to Nextcloud with an admin user (e.g. Administrator) and switch to Settings -> Apps. Look for External Storage support and click Enable. Once the files_external app is enabled, external storage mounts can be configured via Settings -> Administration -> External Storages. To configure external storages the share's windows domain must be set in Nextcloud. Note that the windows domain might change between Samba updates. The windows domain can be obtained via UCR:
ucr get windows/domain
A mount for home shares can be configured very easily with a generic mount. Configure the mount as follows and save it by clicking on the small tick icon. A red square (bad) or green circle (good) tells you whether access to the share was successful, with the currently logged in user.
|Folder name||External Storage||Authentication||Configuration/Host||Configuration/Share||Configuration/Remote Subfolder||Configuration/Domain||Available for|
|Home||SMB/CIFS||Log-in credentials, save in session||<HOST or IP>||/||$user||<WINDOWS DOMAIN>|
The packages mentioned in the following paragraphs require the roles feature, introduced in UCS@school 4.3 v4. To enable it, execute the following on your UCS domaincontroller master:
ucr set ucsschool/feature/roles=yes /usr/share/ucs-school-import/scripts/migrate_ucsschool_roles --all-objects --modify
Since mounts for classes and workgroups can't be configured as generic as the home shares, Univention developed a package for that purpose. It automatically checks all groups that are enabled for Nextcloud and configures a mount for a share of the same name, if there is one. If a Domain Users <OU> group is enabled, it configures the common share Marktplatz for that group. The package comes from the Cool Solutions Repository and must be installed on the UCS server on which the Nextcloud app is installed.
By default a common share called "Marktplatz" is configured for every school in UCS@school. Users can also create more shares available for all users via the web interface and mount them for all users in the Windows logon scripts using the UCR variable ucsschool/userlogon/commonshares.
To also configure a mount for all common shares on a certain server, the package univention-nextcloud-samba-common-share-config from the Cool Solutions Repository can be used. It is triggered on changes of ucsschool/userlogon/commonshares and configures a mount for the shares from that variable on a remote Nextcloud host. The Nextcloud host must be reachable via SSH from the system, where univention-nextcloud-samba-common-share-config is installed!
First, set a few variables to configure univention-nextcloud-samba-common-share-config:
ucr set nextcloud-samba-share-config/remoteUser=<USER to SSH into remote Nextcloud host> ucr set nextcloud-samba-share-config/remotePwFile=<PASSWORD FILE for USER on remote Nextcloud host> ucr set nextcloud-samba-share-config/remoteHost=<HOSTNAME or IP of remote Nextcloud host> ucr set nextcloud-samba-share-config/nextcloudGroup=<GROUP to allow acces to the common shares, should be Domain Users <OU> in most cases>
Afterwards the package can be installed:
Make sure to separate common shares with commas and no additional spaces like so:
ucr set ucsschool/userlogon/commonshares=share1,share2