prepare.go 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package prepare
  2. import (
  3. "os"
  4. "strings"
  5. "github.com/rancher/os/config"
  6. "github.com/rancher/os/pkg/dfs"
  7. "github.com/rancher/os/pkg/log"
  8. )
  9. var (
  10. mountConfig = dfs.Config{
  11. CgroupHierarchy: map[string]string{
  12. "cpu": "cpu",
  13. "cpuacct": "cpu",
  14. "net_cls": "net_cls",
  15. "net_prio": "net_cls",
  16. },
  17. }
  18. )
  19. func FS(c *config.CloudConfig) (*config.CloudConfig, error) {
  20. return c, dfs.PrepareFs(&mountConfig)
  21. }
  22. func SaveCmdline(c *config.CloudConfig) (*config.CloudConfig, error) {
  23. // the Kernel Patch added for RancherOS passes `--` (only) elided kernel boot params to the init process
  24. cmdLineArgs := strings.Join(os.Args, " ")
  25. config.SaveInitCmdline(cmdLineArgs)
  26. cfg := config.LoadConfig()
  27. log.Debugf("Cmdline debug = %t", cfg.Rancher.Debug)
  28. if cfg.Rancher.Debug {
  29. log.SetLevel(log.DebugLevel)
  30. } else {
  31. log.SetLevel(log.InfoLevel)
  32. }
  33. return cfg, nil
  34. }