cli.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package control
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/codegangsta/cli"
  6. "github.com/rancher/os/cmd/control/service"
  7. "github.com/rancher/os/config"
  8. "github.com/rancher/os/log"
  9. )
  10. func Main() {
  11. log.InitLogger()
  12. app := cli.NewApp()
  13. app.Name = os.Args[0]
  14. app.Usage = fmt.Sprintf("Control and configure RancherOS\nbuilt: %s", config.BuildDate)
  15. app.Version = config.Version
  16. app.Author = "Rancher Labs, Inc."
  17. app.EnableBashCompletion = true
  18. app.Before = func(c *cli.Context) error {
  19. if os.Geteuid() != 0 {
  20. log.Fatalf("%s: Need to be root", os.Args[0])
  21. }
  22. return nil
  23. }
  24. app.Commands = []cli.Command{
  25. {
  26. Name: "bootstrap",
  27. Hidden: true,
  28. HideHelp: true,
  29. SkipFlagParsing: true,
  30. Action: bootstrapAction,
  31. },
  32. {
  33. Name: "config",
  34. ShortName: "c",
  35. Usage: "configure settings",
  36. HideHelp: true,
  37. Subcommands: configSubcommands(),
  38. },
  39. {
  40. Name: "console",
  41. Usage: "manage which console container is used",
  42. HideHelp: true,
  43. Subcommands: consoleSubcommands(),
  44. },
  45. {
  46. Name: "console-init",
  47. Hidden: true,
  48. HideHelp: true,
  49. SkipFlagParsing: true,
  50. Action: consoleInitAction,
  51. },
  52. {
  53. Name: "dev",
  54. Hidden: true,
  55. HideHelp: true,
  56. SkipFlagParsing: true,
  57. Action: devAction,
  58. },
  59. {
  60. Name: "docker-init",
  61. Hidden: true,
  62. HideHelp: true,
  63. SkipFlagParsing: true,
  64. Action: dockerInitAction,
  65. },
  66. {
  67. Name: "engine",
  68. Usage: "manage which Docker engine is used",
  69. HideHelp: true,
  70. Subcommands: engineSubcommands(),
  71. },
  72. {
  73. Name: "entrypoint",
  74. Hidden: true,
  75. HideHelp: true,
  76. SkipFlagParsing: true,
  77. Action: entrypointAction,
  78. },
  79. {
  80. Name: "env",
  81. Hidden: true,
  82. HideHelp: true,
  83. SkipFlagParsing: true,
  84. Action: envAction,
  85. },
  86. service.Commands(),
  87. {
  88. Name: "os",
  89. Usage: "operating system upgrade/downgrade",
  90. HideHelp: true,
  91. Subcommands: osSubcommands(),
  92. },
  93. {
  94. Name: "preload-images",
  95. Hidden: true,
  96. HideHelp: true,
  97. SkipFlagParsing: true,
  98. Action: preloadImagesAction,
  99. },
  100. {
  101. Name: "recovery-init",
  102. Hidden: true,
  103. HideHelp: true,
  104. SkipFlagParsing: true,
  105. Action: recoveryInitAction,
  106. },
  107. {
  108. Name: "switch-console",
  109. Hidden: true,
  110. HideHelp: true,
  111. SkipFlagParsing: true,
  112. Action: switchConsoleAction,
  113. },
  114. {
  115. Name: "tls",
  116. Usage: "setup tls configuration",
  117. HideHelp: true,
  118. Subcommands: tlsConfCommands(),
  119. },
  120. {
  121. Name: "udev-settle",
  122. Hidden: true,
  123. HideHelp: true,
  124. SkipFlagParsing: true,
  125. Action: udevSettleAction,
  126. },
  127. {
  128. Name: "user-docker",
  129. Hidden: true,
  130. HideHelp: true,
  131. SkipFlagParsing: true,
  132. Action: userDockerAction,
  133. },
  134. installCommand,
  135. selinuxCommand(),
  136. }
  137. app.Run(os.Args)
  138. }