mirror of
https://github.com/danderson/netboot.git
synced 2025-08-12 17:47:18 +02:00
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:
parent
7ffbdcadd2
commit
b43c25904b
@ -14,7 +14,12 @@
|
|||||||
|
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"go.universe.tf/netboot/pixiecore"
|
||||||
|
)
|
||||||
|
|
||||||
var bootCmd = &cobra.Command{
|
var bootCmd = &cobra.Command{
|
||||||
Use: "boot kernel [initrd...]",
|
Use: "boot kernel [initrd...]",
|
||||||
@ -24,16 +29,36 @@ var bootCmd = &cobra.Command{
|
|||||||
fatalf("you must specify at least a kernel")
|
fatalf("you must specify at least a kernel")
|
||||||
}
|
}
|
||||||
kernel := args[0]
|
kernel := args[0]
|
||||||
initrd := args[1:]
|
initrds := args[1:]
|
||||||
cmdline, err := cmd.Flags().GetString("cmdline")
|
cmdline, err := cmd.Flags().GetString("cmdline")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("Error reading flag: %s", err)
|
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() {
|
func init() {
|
||||||
rootCmd.AddCommand(bootCmd)
|
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")
|
||||||
}
|
}
|
||||||
|
@ -27,19 +27,6 @@ import (
|
|||||||
//
|
//
|
||||||
// Takes a map of ipxe bootloader binaries for various architectures.
|
// Takes a map of ipxe bootloader binaries for various architectures.
|
||||||
func CLI(ipxe map[pixiecore.Firmware][]byte) {
|
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 {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user