func main() { defer func() { if r := recover(); r != nil { log.Errorf("run time panic: %s : %s", r, debug.Stack()) } reboot() }() src, err := extraconfig.GuestInfoSourceWithPrefix("init") if err != nil { log.Error(err) return } extraconfig.Decode(src, &config) debugLevel = config.Diagnostics.DebugLevel if debugLevel > 2 { enableShell() } setLogLevels() logFile, err := os.OpenFile("/dev/ttyS1", os.O_WRONLY|os.O_SYNC, 0644) if err != nil { log.Errorf("Could not pipe stderr to serial for debugging info. Some debug info may be lost! Error reported was %s", err) } err = syscall.Dup3(int(logFile.Fd()), int(os.Stderr.Fd()), 0) if err != nil { log.Errorf("Could not pipe logfile to standard error due to error %s", err) } _, err = os.Stderr.WriteString("all stderr redirected to debug log") if err != nil { log.Errorf("Could not write to Stderr due to error %s", err) } sink, err := extraconfig.GuestInfoSinkWithPrefix("init") if err != nil { log.Error(err) return } // create the tether tthr = tether.New(src, sink, &operations{}) // register the toolbox extension and configure for appliance toolbox := configureToolbox(tether.NewToolbox()) toolbox.PrimaryIP = externalIP tthr.Register("Toolbox", toolbox) err = tthr.Start() if err != nil { log.Error(err) return } log.Info("Clean exit from init") }
func main() { defer func() { if r := recover(); r != nil { log.Errorf("run time panic: %s : %s", r, debug.Stack()) } reboot() }() if strings.HasSuffix(os.Args[0], "-debug") { extraconfig.DecodeLogLevel = log.DebugLevel extraconfig.EncodeLogLevel = log.DebugLevel } log.SetLevel(log.DebugLevel) src, err := extraconfig.GuestInfoSourceWithPrefix("init") if err != nil { log.Error(err) return } sink, err := extraconfig.GuestInfoSinkWithPrefix("init") if err != nil { log.Error(err) return } // create the tether tthr = tether.New(src, sink, &operations{}) // register the toolbox extension tthr.Register("Toolbox", tether.NewToolbox()) err = tthr.Start() if err != nil { log.Error(err) return } log.Info("Clean exit from init") }