udevsettle.go 642 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package control
  2. import (
  3. "os"
  4. "os/exec"
  5. "github.com/codegangsta/cli"
  6. "github.com/rancher/os/log"
  7. )
  8. func udevSettleAction(c *cli.Context) {
  9. if err := UdevSettle(); err != nil {
  10. log.Fatal(err)
  11. }
  12. }
  13. func UdevSettle() error {
  14. cmd := exec.Command("udevd", "--daemon")
  15. cmd.Stdout = os.Stdout
  16. cmd.Stderr = os.Stderr
  17. if err := cmd.Run(); err != nil {
  18. return err
  19. }
  20. cmd = exec.Command("udevadm", "trigger", "--action=add")
  21. cmd.Stdout = os.Stdout
  22. cmd.Stderr = os.Stderr
  23. if err := cmd.Run(); err != nil {
  24. return err
  25. }
  26. cmd = exec.Command("udevadm", "settle")
  27. cmd.Stdout = os.Stdout
  28. cmd.Stderr = os.Stderr
  29. return cmd.Run()
  30. }