exportNFSConfig ensures the NFS export entry exists in /etc/exports, then reloads.
()
| 268 | |
| 269 | // exportNFSConfig ensures the NFS export entry exists in /etc/exports, then reloads. |
| 270 | func (n *NFSServerSetup) exportNFSConfig() error { |
| 271 | // rw: readable and writable |
| 272 | // sync: synchronous writes for better integrity |
| 273 | // no_subtree_check: avoid subtree checking which can cause permission issues |
| 274 | // no_root_squash: allow root user on client to have root permissions on NFS (needed for celer's chattr +a) |
| 275 | exportLine := n.nfsDir + " *(rw,sync,no_subtree_check,no_root_squash)" |
| 276 | if err := fileio.ReplaceContent(nfsExportsPath, exportLine, func(line string) bool { |
| 277 | fields := strings.Fields(line) |
| 278 | return len(fields) > 0 && fields[0] == n.nfsDir |
| 279 | }); err != nil { |
| 280 | return fmt.Errorf("failed to update NFS export entry -> %w", err) |
| 281 | } |
| 282 | color.PrintHint("✔ add NFS export entry %q to %q", exportLine, nfsExportsPath) |
| 283 | |
| 284 | return n.reloadNFSExports() |
| 285 | } |
| 286 | |
| 287 | func (n *NFSServerSetup) removeNFSExportEntry() error { |
| 288 | if err := fileio.RemoveContent(nfsExportsPath, func(line string) bool { |
no test coverage detected