MCPcopy Index your code
hub / github.com/celer-pkg/celer / installChattrCronJob

Method installChattrCronJob

pkgcache/cache_setup.go:319–330  ·  view source on GitHub ↗

installChattrCronJob installs a cron job that runs "find -type d -exec chattr +a" every minute, ensuring directories created by NFS clients are protected.

(username string)

Source from the content-addressed store, hash-verified

317// installChattrCronJob installs a cron job that runs "find <nfs-dir> -type d -exec chattr +a"
318// every minute, ensuring directories created by NFS clients are protected.
319func (n *NFSServerSetup) installChattrCronJob(username string) error {
320 // * * * * * - everytime
321 // 2>/dev/null - execute quietly
322 cronContent := fmt.Sprintf("* * * * * root /usr/bin/find %s -type d -exec /usr/bin/chattr +a {} + 2>/dev/null\n", shellQuote(n.nfsDir))
323 cronPath := filepath.Join(nfsCronDir, fmt.Sprintf("%s-chattr", username))
324
325 if err := os.WriteFile(cronPath, []byte(cronContent), 0644); err != nil {
326 return fmt.Errorf("failed to write cron file -> %w", err)
327 }
328 color.PrintHint("✔ add chattr cron job: %s", cronPath)
329 return nil
330}
331
332func (n *NFSServerSetup) removeChattrCronJob(username string) error {
333 cronPath := filepath.Join(nfsCronDir, fmt.Sprintf("%s-chattr", username))

Callers 1

SetupMethod · 0.95

Calls 4

PrintHintFunction · 0.92
shellQuoteFunction · 0.85
SprintfMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected