Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #35 from sidharthamani/master
Browse files Browse the repository at this point in the history
add shutdown command
  • Loading branch information
ibuildthecloud committed Feb 23, 2015
2 parents 1c5ac9f + 8181e26 commit f6b2c84
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cmd/power/shutdown.go
Original file line number Diff line number Diff line change
@@ -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()
}
}

1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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 " +
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f6b2c84

Please sign in to comment.