MCPcopy Create free account
hub / github.com/celer-pkg/celer / exportNFSConfig

Method exportNFSConfig

pkgcache/cache_setup.go:270–285  ·  view source on GitHub ↗

exportNFSConfig ensures the NFS export entry exists in /etc/exports, then reloads.

()

Source from the content-addressed store, hash-verified

268
269// exportNFSConfig ensures the NFS export entry exists in /etc/exports, then reloads.
270func (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
287func (n *NFSServerSetup) removeNFSExportEntry() error {
288 if err := fileio.RemoveContent(nfsExportsPath, func(line string) bool {

Callers 1

SetupMethod · 0.95

Calls 3

reloadNFSExportsMethod · 0.95
ReplaceContentFunction · 0.92
PrintHintFunction · 0.92

Tested by

no test coverage detected