2015-06-22 10:31:12 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
|
2015-06-30 07:49:13 +08:00
|
|
|
"github.com/Sirupsen/logrus"
|
2015-06-22 10:31:12 +08:00
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var specCommand = cli.Command{
|
|
|
|
Name: "spec",
|
|
|
|
Usage: "create a new specification file",
|
|
|
|
Action: func(context *cli.Context) {
|
|
|
|
spec := PortableSpec{
|
|
|
|
Version: version,
|
2015-06-30 02:18:17 +08:00
|
|
|
Platform: Platform{
|
|
|
|
OS: runtime.GOOS,
|
|
|
|
Arch: runtime.GOARCH,
|
|
|
|
},
|
2015-06-22 10:31:12 +08:00
|
|
|
Root: Root{
|
|
|
|
Path: "rootfs",
|
|
|
|
Readonly: true,
|
|
|
|
},
|
2015-06-30 02:21:05 +08:00
|
|
|
Process: Process{
|
|
|
|
Terminal: true,
|
2015-07-02 00:57:26 +08:00
|
|
|
User: User{},
|
2015-06-30 02:21:05 +08:00
|
|
|
Args: []string{
|
|
|
|
"sh",
|
|
|
|
},
|
|
|
|
Env: []string{
|
|
|
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
|
|
"TERM=xterm",
|
2015-06-22 10:31:12 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Hostname: "shell",
|
|
|
|
Mounts: []Mount{
|
|
|
|
{
|
|
|
|
Type: "proc",
|
|
|
|
Source: "proc",
|
|
|
|
Destination: "/proc",
|
|
|
|
Options: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "tmpfs",
|
|
|
|
Source: "tmpfs",
|
|
|
|
Destination: "/dev",
|
|
|
|
Options: "nosuid,strictatime,mode=755,size=65536k",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "devpts",
|
|
|
|
Source: "devpts",
|
|
|
|
Destination: "/dev/pts",
|
|
|
|
Options: "nosuid,noexec,newinstance,ptmxmode=0666,mode=0620,gid=5",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "tmpfs",
|
|
|
|
Source: "shm",
|
|
|
|
Destination: "/dev/shm",
|
|
|
|
Options: "nosuid,noexec,nodev,mode=1777,size=65536k",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "mqueue",
|
|
|
|
Source: "mqueue",
|
|
|
|
Destination: "/dev/mqueue",
|
|
|
|
Options: "nosuid,noexec,nodev",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "sysfs",
|
|
|
|
Source: "sysfs",
|
|
|
|
Destination: "/sys",
|
|
|
|
Options: "nosuid,noexec,nodev",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
data, err := json.MarshalIndent(&spec, "", "\t")
|
|
|
|
if err != nil {
|
2015-06-30 07:49:13 +08:00
|
|
|
logrus.Fatal(err)
|
2015-06-22 10:31:12 +08:00
|
|
|
}
|
|
|
|
fmt.Printf("%s", data)
|
|
|
|
},
|
|
|
|
}
|