cli.go 2.9 KB

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