main.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/containernetworking/cni/plugins/ipam/host-local"
  6. "github.com/containernetworking/cni/plugins/main/bridge"
  7. "github.com/docker/docker/docker"
  8. "github.com/docker/docker/pkg/reexec"
  9. "github.com/rancher/cniglue"
  10. "github.com/rancher/os/cmd/cloudinitexecute"
  11. "github.com/rancher/os/cmd/cloudinitsave"
  12. "github.com/rancher/os/cmd/control"
  13. "github.com/rancher/os/cmd/network"
  14. "github.com/rancher/os/cmd/power"
  15. "github.com/rancher/os/cmd/respawn"
  16. "github.com/rancher/os/cmd/sysinit"
  17. "github.com/rancher/os/cmd/systemdocker"
  18. "github.com/rancher/os/cmd/wait"
  19. "github.com/rancher/os/dfs"
  20. osInit "github.com/rancher/os/init"
  21. )
  22. var entrypoints = map[string]func(){
  23. "autologin": control.AutologinMain,
  24. "cloud-init-execute": cloudinitexecute.Main,
  25. "cloud-init-save": cloudinitsave.Main,
  26. "console": control.ConsoleInitMain,
  27. "console.sh": control.ConsoleInitMain,
  28. "docker": docker.Main,
  29. "dockerlaunch": dfs.Main,
  30. "init": osInit.MainInit,
  31. "netconf": network.Main,
  32. "recovery": control.AutologinMain,
  33. "ros-sysinit": sysinit.Main,
  34. "system-docker": systemdocker.Main,
  35. "wait-for-docker": wait.Main,
  36. "cni-glue": glue.Main,
  37. "bridge": bridge.Main,
  38. "host-local": hostlocal.Main,
  39. "respawn": respawn.Main,
  40. // Power commands
  41. "halt": power.Shutdown,
  42. "poweroff": power.Shutdown,
  43. "reboot": power.Shutdown,
  44. "shutdown": power.Shutdown,
  45. }
  46. func main() {
  47. if 0 == 1 {
  48. // TODO: move this into a "dev/debug +build"
  49. fmt.Fprintf(os.Stderr, "ros main(%s) ppid:%d - print to stdio\n", os.Args[0], os.Getppid())
  50. filename := "/dev/kmsg"
  51. f, err := os.OpenFile(filename, os.O_WRONLY, 0644)
  52. if err == nil {
  53. fmt.Fprintf(f, "ros main(%s) ppid:%d - print to %s\n", os.Args[0], os.Getppid(), filename)
  54. }
  55. f.Close()
  56. }
  57. for name, f := range entrypoints {
  58. reexec.Register(name, f)
  59. }
  60. if !reexec.Init() {
  61. control.Main()
  62. }
  63. }