2015-02-17 14:31:37 -07:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-03-03 14:02:44 +10:00
|
|
|
|
2015-02-17 14:31:37 -07:00
|
|
|
"github.com/codegangsta/cli"
|
2016-10-21 21:17:40 -07:00
|
|
|
"github.com/rancher/os/cmd/control/service"
|
2015-10-12 19:50:17 +08:00
|
|
|
"github.com/rancher/os/config"
|
2016-11-23 20:49:35 +10:00
|
|
|
"github.com/rancher/os/log"
|
2015-02-17 14:31:37 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func Main() {
|
2016-11-23 20:49:35 +10:00
|
|
|
log.InitLogger()
|
2015-02-17 14:31:37 -07:00
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
app.Name = os.Args[0]
|
|
|
|
app.Usage = "Control and configure RancherOS"
|
2016-11-28 00:06:00 -08:00
|
|
|
app.Version = config.Version
|
2015-02-17 14:31:37 -07:00
|
|
|
app.Author = "Rancher Labs, Inc."
|
2015-02-22 20:56:25 -07:00
|
|
|
app.EnableBashCompletion = true
|
2016-03-16 17:48:57 +08:00
|
|
|
app.Before = func(c *cli.Context) error {
|
|
|
|
if os.Geteuid() != 0 {
|
|
|
|
log.Fatalf("%s: Need to be root", os.Args[0])
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2015-02-17 14:31:37 -07:00
|
|
|
|
|
|
|
app.Commands = []cli.Command{
|
2016-10-17 14:47:44 -07:00
|
|
|
{
|
2017-03-14 12:11:24 +10:00
|
|
|
Name: "bootstrap",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: bootstrapAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "config",
|
|
|
|
ShortName: "c",
|
|
|
|
Usage: "configure settings",
|
|
|
|
HideHelp: true,
|
|
|
|
Subcommands: configSubcommands(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "console",
|
|
|
|
Usage: "manage which console container is used",
|
|
|
|
HideHelp: true,
|
|
|
|
Subcommands: consoleSubcommands(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "console-init",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: consoleInitAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "dev",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: devAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "docker-init",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: dockerInitAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "engine",
|
|
|
|
Usage: "manage which Docker engine is used",
|
|
|
|
HideHelp: true,
|
|
|
|
Subcommands: engineSubcommands(),
|
2015-07-21 12:56:55 +05:00
|
|
|
},
|
2016-10-20 11:58:34 -07:00
|
|
|
{
|
2017-03-14 12:11:24 +10:00
|
|
|
Name: "entrypoint",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: entrypointAction,
|
2016-10-20 11:58:34 -07:00
|
|
|
},
|
2016-08-15 15:06:26 -07:00
|
|
|
{
|
2017-03-14 12:11:24 +10:00
|
|
|
Name: "env",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: envAction,
|
2016-08-14 19:17:24 -07:00
|
|
|
},
|
2017-03-14 12:11:24 +10:00
|
|
|
service.Commands(),
|
2015-04-29 15:32:12 +05:00
|
|
|
{
|
2017-03-14 12:11:24 +10:00
|
|
|
Name: "os",
|
|
|
|
Usage: "operating system upgrade/downgrade",
|
|
|
|
HideHelp: true,
|
|
|
|
Subcommands: osSubcommands(),
|
2015-04-29 15:32:12 +05:00
|
|
|
},
|
2017-03-14 12:11:24 +10:00
|
|
|
{
|
|
|
|
Name: "preload-images",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: preloadImagesAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "switch-console",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: switchConsoleAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "tls",
|
|
|
|
Usage: "setup tls configuration",
|
|
|
|
HideHelp: true,
|
|
|
|
Subcommands: tlsConfCommands(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "udev-settle",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: udevSettleAction,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "user-docker",
|
|
|
|
Hidden: true,
|
|
|
|
HideHelp: true,
|
|
|
|
SkipFlagParsing: true,
|
|
|
|
Action: userDockerAction,
|
|
|
|
},
|
|
|
|
installCommand,
|
|
|
|
selinuxCommand(),
|
2015-02-17 14:31:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
}
|