This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from sidharthamani/master
add shutdown command
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters