2014-10-17 08:00:59 +08:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
|
2014-12-25 23:43:05 +08:00
|
|
|
"github.com/docker/libcontainer"
|
2015-02-03 18:53:31 +08:00
|
|
|
_ "github.com/docker/libcontainer/nsenter"
|
2014-10-17 08:00:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// init runs the libcontainer initialization code because of the busybox style needs
|
|
|
|
// to work around the go runtime and the issues with forking
|
|
|
|
func init() {
|
|
|
|
if len(os.Args) < 2 || os.Args[1] != "init" {
|
|
|
|
return
|
|
|
|
}
|
2015-02-11 03:51:45 +08:00
|
|
|
runtime.GOMAXPROCS(1)
|
2014-10-17 08:00:59 +08:00
|
|
|
runtime.LockOSThread()
|
2015-02-14 07:43:14 +08:00
|
|
|
factory, err := libcontainer.New("")
|
2014-12-25 23:43:05 +08:00
|
|
|
if err != nil {
|
2014-10-17 08:00:59 +08:00
|
|
|
log.Fatalf("unable to initialize for container: %s", err)
|
|
|
|
}
|
2015-04-09 05:14:51 +08:00
|
|
|
if err := factory.StartInitialization(); err != nil {
|
2015-02-17 05:09:00 +08:00
|
|
|
log.Fatal(err)
|
2014-10-17 08:00:59 +08:00
|
|
|
}
|
|
|
|
}
|