1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 14:23:11 +00:00
Files
os/main.go

56 lines
1.5 KiB
Go
Raw Normal View History

2015-02-08 21:38:37 -07:00
package main
import (
"os"
2015-02-17 14:31:20 -07:00
"strings"
2015-02-08 21:38:37 -07:00
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/reexec"
2015-02-19 14:43:37 -07:00
"github.com/rancherio/os/cmd/cloudinit"
2015-02-17 14:31:20 -07:00
"github.com/rancherio/os/cmd/control"
2015-04-04 09:55:41 -07:00
"github.com/rancherio/os/cmd/network"
2015-02-19 13:56:33 -07:00
"github.com/rancherio/os/cmd/power"
2015-02-19 13:53:52 -07:00
"github.com/rancherio/os/cmd/respawn"
2015-02-19 13:58:29 -07:00
"github.com/rancherio/os/cmd/sysinit"
2015-02-17 14:31:20 -07:00
"github.com/rancherio/os/cmd/systemdocker"
2015-04-04 09:55:41 -07:00
"github.com/rancherio/os/cmd/wait"
2015-02-08 21:38:37 -07:00
osInit "github.com/rancherio/os/init"
)
2015-02-17 14:31:20 -07:00
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)
}
2015-02-08 21:38:37 -07:00
func main() {
2015-02-17 14:31:20 -07:00
registerCmd("/init", osInit.MainInit)
2015-02-19 13:58:29 -07:00
registerCmd(osInit.SYSINIT, sysinit.Main)
2015-02-17 14:31:20 -07:00
registerCmd("/usr/bin/system-docker", systemdocker.Main)
registerCmd("/sbin/poweroff", power.PowerOff)
registerCmd("/sbin/reboot", power.Reboot)
registerCmd("/sbin/halt", power.Halt)
2015-02-22 21:07:59 -08:00
registerCmd("/sbin/shutdown", power.Main)
2015-02-17 14:31:20 -07:00
registerCmd("/usr/bin/respawn", respawn.Main)
registerCmd("/usr/sbin/rancherctl", control.Main)
2015-02-19 20:05:43 -07:00
registerCmd("/usr/bin/cloud-init", cloudinit.Main)
2015-03-02 15:03:21 -08:00
registerCmd("/usr/sbin/netconf", network.Main)
2015-04-04 09:55:41 -07:00
registerCmd("/usr/sbin/wait-for-docker", wait.Main)
2015-02-17 17:31:19 -07:00
2015-02-08 21:38:37 -07:00
if !reexec.Init() {
log.Fatalf("Failed to find an entry point for %s", os.Args[0])
}
}