2015-02-09 04:38:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-05-02 23:45:58 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2016-06-01 04:38:10 +00:00
|
|
|
"github.com/docker/docker/docker"
|
2015-02-09 04:38:37 +00:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2016-08-04 22:47:12 +00:00
|
|
|
"github.com/rancher/os/cmd/cloudinitexecute"
|
|
|
|
"github.com/rancher/os/cmd/cloudinitsave"
|
2015-10-12 11:50:17 +00:00
|
|
|
"github.com/rancher/os/cmd/control"
|
|
|
|
"github.com/rancher/os/cmd/network"
|
|
|
|
"github.com/rancher/os/cmd/power"
|
|
|
|
"github.com/rancher/os/cmd/respawn"
|
|
|
|
"github.com/rancher/os/cmd/sysinit"
|
|
|
|
"github.com/rancher/os/cmd/wait"
|
2016-10-19 23:21:35 +00:00
|
|
|
"github.com/rancher/os/dfs"
|
2015-10-12 11:50:17 +00:00
|
|
|
osInit "github.com/rancher/os/init"
|
2015-02-09 04:38:37 +00:00
|
|
|
)
|
|
|
|
|
2016-06-01 04:38:10 +00:00
|
|
|
var entrypoints = map[string]func(){
|
2017-06-20 11:48:14 +00:00
|
|
|
"autologin": control.AutologinMain,
|
2016-08-04 22:47:12 +00:00
|
|
|
"cloud-init-execute": cloudinitexecute.Main,
|
|
|
|
"cloud-init-save": cloudinitsave.Main,
|
2017-02-02 14:05:18 +00:00
|
|
|
"console": control.ConsoleInitMain,
|
|
|
|
"console.sh": control.ConsoleInitMain,
|
2016-08-04 22:47:12 +00:00
|
|
|
"docker": docker.Main,
|
2016-10-19 23:21:35 +00:00
|
|
|
"dockerlaunch": dfs.Main,
|
2016-08-04 22:47:12 +00:00
|
|
|
"init": osInit.MainInit,
|
|
|
|
"netconf": network.Main,
|
2017-07-16 01:50:01 +00:00
|
|
|
"recovery": control.AutologinMain,
|
2017-09-13 06:02:53 +00:00
|
|
|
"ros-bootstrap": control.BootstrapMain,
|
2016-08-04 22:47:12 +00:00
|
|
|
"ros-sysinit": sysinit.Main,
|
|
|
|
"wait-for-docker": wait.Main,
|
2017-07-05 04:14:22 +00:00
|
|
|
"respawn": respawn.Main,
|
|
|
|
|
|
|
|
// Power commands
|
|
|
|
"halt": power.Shutdown,
|
|
|
|
"poweroff": power.Shutdown,
|
|
|
|
"reboot": power.Shutdown,
|
|
|
|
"shutdown": power.Shutdown,
|
2015-02-17 21:31:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-09 04:38:37 +00:00
|
|
|
func main() {
|
2017-05-02 23:45:58 +00:00
|
|
|
if 0 == 1 {
|
|
|
|
// TODO: move this into a "dev/debug +build"
|
|
|
|
fmt.Fprintf(os.Stderr, "ros main(%s) ppid:%d - print to stdio\n", os.Args[0], os.Getppid())
|
|
|
|
|
|
|
|
filename := "/dev/kmsg"
|
|
|
|
f, err := os.OpenFile(filename, os.O_WRONLY, 0644)
|
|
|
|
if err == nil {
|
|
|
|
fmt.Fprintf(f, "ros main(%s) ppid:%d - print to %s\n", os.Args[0], os.Getppid(), filename)
|
|
|
|
}
|
|
|
|
f.Close()
|
|
|
|
}
|
|
|
|
|
2016-06-01 04:38:10 +00:00
|
|
|
for name, f := range entrypoints {
|
|
|
|
reexec.Register(name, f)
|
|
|
|
}
|
2015-02-18 00:31:19 +00:00
|
|
|
|
2015-02-09 04:38:37 +00:00
|
|
|
if !reexec.Init() {
|
2016-06-01 04:38:10 +00:00
|
|
|
control.Main()
|
2015-02-09 04:38:37 +00:00
|
|
|
}
|
|
|
|
}
|