How-To: Remove NFS Option from multiple shares

Environment

You have multiple shares with option nfs and want to remove the nfs feature.

Using a Terminal

This only works with UCS 4.4-x and above!

Step 1: collect the dn's of the shares to work with

Either you write all dn's line by line into a file, or you use a ldapsearch.

ldapsearch example

root@ucs:~# univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=univentionShareNFS)(univentionShareHost=<FQDN>))" 1.1 | sed '/^$/d'

You might than use a loop to iterate through your list of shares to modify them via udm

using a file

while read -r dn; do
  udm shares/share modify --dn "$dn" --remove-option nfs
done < share_dns.lst

using ldapsearch

while read -r dn; do
  udm shares/share modify --dn "$dn" --remove-option nfs
done <<<$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=univentionShareNFS)(univentionShareHost=<FQDN>))" 1.1 | sed '/^$/d')
Mastodon