forked from rancher/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (47 loc) · 1.56 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
package main
import (
"os"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/reexec"
"github.com/rancherio/os/cmd/cloudinit"
"github.com/rancherio/os/cmd/control"
"github.com/rancherio/os/cmd/network"
"github.com/rancherio/os/cmd/power"
"github.com/rancherio/os/cmd/respawn"
"github.com/rancherio/os/cmd/sysinit"
"github.com/rancherio/os/cmd/systemdocker"
"github.com/rancherio/os/cmd/wait"
osInit "github.com/rancherio/os/init"
)
func registerCmd(cmd string, mainFunc func()) {
log.Debugf("Registering main %s", cmd)
reexec.Register(cmd, mainFunc)
parts := strings.Split(cmd, "/")
if len(parts) == 0 {
return
}
last := parts[len(parts)-1]
log.Debugf("Registering main %s", last)
reexec.Register(last, mainFunc)
log.Debugf("Registering main %s", "./"+last)
reexec.Register("./"+last, mainFunc)
}
func main() {
registerCmd("/init", osInit.MainInit)
registerCmd(osInit.SYSINIT, sysinit.Main)
registerCmd("/usr/bin/system-docker", systemdocker.Main)
registerCmd("/sbin/poweroff", power.PowerOff)
registerCmd("/sbin/reboot", power.Reboot)
registerCmd("/sbin/halt", power.Halt)
registerCmd("/sbin/shutdown", power.Main)
registerCmd("/usr/bin/respawn", respawn.Main)
registerCmd("/usr/sbin/rancherctl", control.Main) // deprecated, use `ros` instead
registerCmd("/usr/sbin/ros", control.Main)
registerCmd("/usr/bin/cloud-init", cloudinit.Main)
registerCmd("/usr/sbin/netconf", network.Main)
registerCmd("/usr/sbin/wait-for-docker", wait.Main)
if !reexec.Init() {
log.Fatalf("Failed to find an entry point for %s", os.Args[0])
}
}