2015-02-09 04:38:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2015-02-17 21:31:20 +00:00
|
|
|
"strings"
|
2015-02-09 04:38:37 +00:00
|
|
|
|
|
|
|
log "github.com/Sirupsen/logrus"
|
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2015-08-04 21:45:38 +00:00
|
|
|
dockerlaunchMain "github.com/rancher/docker-from-scratch/main"
|
2015-02-19 21:43:37 +00:00
|
|
|
"github.com/rancherio/os/cmd/cloudinit"
|
2015-02-17 21:31:20 +00:00
|
|
|
"github.com/rancherio/os/cmd/control"
|
2015-04-04 16:55:41 +00:00
|
|
|
"github.com/rancherio/os/cmd/network"
|
2015-02-19 20:56:33 +00:00
|
|
|
"github.com/rancherio/os/cmd/power"
|
2015-02-19 20:53:52 +00:00
|
|
|
"github.com/rancherio/os/cmd/respawn"
|
2015-02-19 20:58:29 +00:00
|
|
|
"github.com/rancherio/os/cmd/sysinit"
|
2015-02-17 21:31:20 +00:00
|
|
|
"github.com/rancherio/os/cmd/systemdocker"
|
2015-08-27 19:24:26 +00:00
|
|
|
"github.com/rancherio/os/cmd/userdocker"
|
2015-04-04 16:55:41 +00:00
|
|
|
"github.com/rancherio/os/cmd/wait"
|
2015-07-29 07:51:49 +00:00
|
|
|
"github.com/rancherio/os/config"
|
2015-02-09 04:38:37 +00:00
|
|
|
osInit "github.com/rancherio/os/init"
|
|
|
|
)
|
|
|
|
|
2015-02-17 21:31:20 +00: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-09 04:38:37 +00:00
|
|
|
func main() {
|
2015-02-17 21:31:20 +00:00
|
|
|
registerCmd("/init", osInit.MainInit)
|
2015-07-29 07:51:49 +00:00
|
|
|
registerCmd(config.SYSINIT_BIN, sysinit.Main)
|
2015-08-04 21:45:38 +00:00
|
|
|
registerCmd("/usr/bin/dockerlaunch", dockerlaunchMain.Main)
|
2015-08-27 19:24:26 +00:00
|
|
|
registerCmd("/usr/bin/user-docker", userdocker.Main)
|
2015-02-17 21:31:20 +00: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-23 05:07:59 +00:00
|
|
|
registerCmd("/sbin/shutdown", power.Main)
|
2015-02-17 21:31:20 +00:00
|
|
|
registerCmd("/usr/bin/respawn", respawn.Main)
|
2015-05-10 13:05:09 +00:00
|
|
|
registerCmd("/usr/sbin/rancherctl", control.Main) // deprecated, use `ros` instead
|
|
|
|
registerCmd("/usr/sbin/ros", control.Main)
|
2015-02-20 03:05:43 +00:00
|
|
|
registerCmd("/usr/bin/cloud-init", cloudinit.Main)
|
2015-03-02 23:03:21 +00:00
|
|
|
registerCmd("/usr/sbin/netconf", network.Main)
|
2015-04-04 16:55:41 +00:00
|
|
|
registerCmd("/usr/sbin/wait-for-docker", wait.Main)
|
2015-02-18 00:31:19 +00:00
|
|
|
|
2015-02-09 04:38:37 +00:00
|
|
|
if !reexec.Init() {
|
|
|
|
log.Fatalf("Failed to find an entry point for %s", os.Args[0])
|
|
|
|
}
|
|
|
|
}
|