forked from rancher/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (52 loc) · 1.53 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"os"
"github.com/rancher/os/cmd/cloudinitexecute"
"github.com/rancher/os/cmd/cloudinitsave"
"github.com/rancher/os/cmd/control"
osInit "github.com/rancher/os/cmd/init"
"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"
"github.com/rancher/os/pkg/dfs"
"github.com/docker/docker/pkg/reexec"
)
var entrypoints = map[string]func(){
"autologin": control.AutologinMain,
"cloud-init-execute": cloudinitexecute.Main,
"cloud-init-save": cloudinitsave.Main,
"dockerlaunch": dfs.Main,
"init": osInit.MainInit,
"netconf": network.Main,
"recovery": control.AutologinMain,
"ros-bootstrap": control.BootstrapMain,
"ros-sysinit": sysinit.Main,
"wait-for-docker": wait.Main,
"respawn": respawn.Main,
// Power commands
"halt": power.Shutdown,
"poweroff": power.Shutdown,
"reboot": power.Shutdown,
"shutdown": power.Shutdown,
}
func main() {
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()
}
for name, f := range entrypoints {
reexec.Register(name, f)
}
if !reexec.Init() {
control.Main()
}
}