1
0
mirror of https://github.com/rancher/os.git synced 2025-08-02 07:24:28 +00:00

add shutdown command

This commit is contained in:
sidharthamani 2015-02-22 21:07:59 -08:00
parent d2dd4db6b1
commit 8181e2633a
3 changed files with 51 additions and 0 deletions

49
cmd/power/shutdown.go Normal file
View File

@ -0,0 +1,49 @@
package power
import(
"fmt"
"os"
"github.com/codegangsta/cli"
"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",
},
}
app.HideHelp = true
app.Run(os.Args)
}
func shutdown(c *cli.Context) {
reboot := c.String("r")
poweroff := c.String("h")
fmt.Println(reboot)
fmt.Println(poweroff)
if reboot == "now" {
Reboot()
} else if poweroff == "now" {
PowerOff()
}
}

View File

@ -37,6 +37,7 @@ func NewConfig() *Config {
"-v=/init:/sbin/halt:ro " +
"-v=/init:/sbin/poweroff:ro " +
"-v=/init:/sbin/reboot:ro " +
"-v=/init:/sbin/shutdown:ro " +
"-v=/init:/usr/bin/cloud-init:ro " +
"-v=/init:/usr/bin/tlsconf:ro " +
"-v=/init:/usr/bin/rancherctl:ro " +

View File

@ -40,6 +40,7 @@ func main() {
registerCmd("/sbin/poweroff", power.PowerOff)
registerCmd("/sbin/reboot", power.Reboot)
registerCmd("/sbin/halt", power.Halt)
registerCmd("/sbin/shutdown", power.Main)
registerCmd("/usr/bin/respawn", respawn.Main)
registerCmd("/usr/sbin/rancherctl", control.Main)
registerCmd("/usr/bin/cloud-init", cloudinit.Main)