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.
This commit is contained in:
David Anderson 2016-08-11 23:29:46 -07:00
parent 7ffbdcadd2
commit b43c25904b
2 changed files with 29 additions and 17 deletions

View File

@ -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")
}

View File

@ -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)