From b43c25904b347bb7a1104202eb6d63455b6aa1a1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 11 Aug 2016 23:29:46 -0700 Subject: [PATCH] pixiecore: implement the boot command, using static booter. Doesn't quite work yet: cmdline isn't processed very well, and the ipxe firmwares aren't plumbed through. --- pixiecore/cli/bootcmd.go | 33 +++++++++++++++++++++++++++++---- pixiecore/cli/cli.go | 13 ------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pixiecore/cli/bootcmd.go b/pixiecore/cli/bootcmd.go index 14c69d9..a558d1c 100644 --- a/pixiecore/cli/bootcmd.go +++ b/pixiecore/cli/bootcmd.go @@ -14,7 +14,12 @@ package cli -import "github.com/spf13/cobra" +import ( + "fmt" + + "github.com/spf13/cobra" + "go.universe.tf/netboot/pixiecore" +) var bootCmd = &cobra.Command{ Use: "boot kernel [initrd...]", @@ -24,16 +29,36 @@ var bootCmd = &cobra.Command{ fatalf("you must specify at least a kernel") } kernel := args[0] - initrd := args[1:] + initrds := args[1:] cmdline, err := cmd.Flags().GetString("cmdline") if err != nil { fatalf("Error reading flag: %s", err) } - todo("run in static mode with kernel=%s, initrd=%v, cmdline=%q", kernel, initrd, cmdline) + bootmsg, err := cmd.Flags().GetString("bootmsg") + if err != nil { + fatalf("Error reading flag: %s", err) + } + + spec := &pixiecore.Spec{ + Kernel: pixiecore.ID(kernel), + Cmdline: map[string]interface{}{cmdline: ""}, + Message: bootmsg, + } + for _, initrd := range initrds { + spec.Initrd = append(spec.Initrd, pixiecore.ID(initrd)) + } + + s := &pixiecore.Server{ + Booter: pixiecore.StaticBooter(spec), + Ipxe: nil, // TODO + Log: func(msg string) { fmt.Println(msg) }, + } + fmt.Println(s.Serve()) }, } func init() { rootCmd.AddCommand(bootCmd) - bootCmd.Flags().StringP("cmdline", "c", "", "Kernel commandline arguments") + bootCmd.Flags().String("cmdline", "", "Kernel commandline arguments") + bootCmd.Flags().String("bootmsg", "", "Message to print on machines before booting") } diff --git a/pixiecore/cli/cli.go b/pixiecore/cli/cli.go index 4e78158..a0f2c67 100644 --- a/pixiecore/cli/cli.go +++ b/pixiecore/cli/cli.go @@ -27,19 +27,6 @@ import ( // // Takes a map of ipxe bootloader binaries for various architectures. func CLI(ipxe map[pixiecore.Firmware][]byte) { - s := &pixiecore.Server{ - Booter: pixiecore.StaticBooter(&pixiecore.Spec{ - Kernel: pixiecore.ID("http://tinycorelinux.net/7.x/x86/release/distribution_files/vmlinuz64"), - Initrd: []pixiecore.ID{ - "http://tinycorelinux.net/7.x/x86/release/distribution_files/rootfs.gz", - "http://tinycorelinux.net/7.x/x86/release/distribution_files/modules64.gz", - }, - }), - Ipxe: ipxe, - Log: func(msg string) { fmt.Println(msg) }, - } - fmt.Println(s.Serve()) - if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(-1)