1
0
mirror of https://github.com/rancher/os.git synced 2025-06-23 21:47:03 +00:00
os/cmd/power/shutdown.go

45 lines
748 B
Go
Raw Normal View History

2015-02-23 05:07:59 +00:00
package power
import (
2015-02-23 05:07:59 +00:00
"os"
"github.com/codegangsta/cli"
2015-02-23 05:07:59 +00:00
"github.com/rancherio/os/config"
)
func Main() {
app := cli.NewApp()
app.Name = os.Args[0]
app.Usage = "Control and configure RancherOS"
app.Version = config.VERSION
app.Author = "Rancher Labs, Inc."
app.Email = "sid@rancher.com"
app.EnableBashCompletion = true
app.Action = shutdown
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "r, R",
Usage: "reboot after shutdown",
},
cli.StringFlag{
Name: "h",
Usage: "halt the system",
},
}
2015-02-23 05:07:59 +00:00
app.HideHelp = true
app.Run(os.Args)
}
func shutdown(c *cli.Context) {
2015-03-19 22:36:40 +00:00
common("")
2015-02-23 05:07:59 +00:00
reboot := c.String("r")
poweroff := c.String("h")
2015-02-23 05:07:59 +00:00
if reboot == "now" {
Reboot()
} else if poweroff == "now" {
PowerOff()
}
}