2014-02-20 08:40:36 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
2014-03-04 13:47:03 +08:00
|
|
|
|
2014-06-05 07:46:30 +08:00
|
|
|
"github.com/codegangsta/cli"
|
2014-02-20 08:40:36 +08:00
|
|
|
)
|
|
|
|
|
2014-06-06 05:28:09 +08:00
|
|
|
var logPath = os.Getenv("log")
|
2014-02-20 12:35:04 +08:00
|
|
|
|
2014-06-06 05:28:09 +08:00
|
|
|
func preload(context *cli.Context) error {
|
2014-06-05 07:46:30 +08:00
|
|
|
if logPath != "" {
|
2014-06-06 05:28:09 +08:00
|
|
|
if err := openLog(logPath); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-05-24 09:06:14 +08:00
|
|
|
}
|
|
|
|
|
2014-06-05 07:46:30 +08:00
|
|
|
return nil
|
2014-02-20 12:35:04 +08:00
|
|
|
}
|
2014-05-14 16:56:55 +08:00
|
|
|
|
2014-06-05 07:46:30 +08:00
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "nsinit"
|
|
|
|
app.Version = "0.1"
|
|
|
|
app.Author = "libcontainer maintainers"
|
2014-05-30 08:23:18 +08:00
|
|
|
|
2014-06-05 07:46:30 +08:00
|
|
|
app.Before = preload
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
execCommand,
|
|
|
|
initCommand,
|
|
|
|
statsCommand,
|
|
|
|
specCommand,
|
2014-06-06 05:28:09 +08:00
|
|
|
nsenterCommand,
|
2014-05-30 08:23:18 +08:00
|
|
|
}
|
|
|
|
|
2014-06-05 07:46:30 +08:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
log.Fatal(err)
|
2014-05-30 08:23:18 +08:00
|
|
|
}
|
|
|
|
}
|