blob: fcbcfa2819f278c4dd44fb9ad767d03b5568fe88 [file] [log] [blame]
Tim Windelschmidt7006caf2024-02-27 16:49:39 +01001package main
2
3import (
4 _ "embed"
5 "log"
6
7 "github.com/spf13/cobra"
8
9 "source.monogon.dev/metropolis/cli/metroctl/core"
10)
11
12var genusbCmd = &cobra.Command{
13 Use: "genusb target",
14 Short: "Generates a Metropolis installer disk or image.",
15 Example: "metroctl install --bundle=metropolis-v0.1.zip genusb /dev/sdx",
Tim Windelschmidtfc6e1cf2024-09-18 17:34:07 +020016 Args: PrintUsageOnWrongArgs(cobra.ExactArgs(1)), // One positional argument: the target
Tim Windelschmidt7006caf2024-02-27 16:49:39 +010017 Run: doGenUSB,
18}
19
20func doGenUSB(cmd *cobra.Command, args []string) {
21 params := makeNodeParams()
22
23 installerPath, err := cmd.Flags().GetString("installer")
24 if err != nil {
25 log.Fatal(err)
26 }
27
28 installer := external("installer", "_main/metropolis/installer/kernel.efi", &installerPath)
29 bundle := external("bundle", "_main/metropolis/node/bundle.zip", bundlePath)
30
31 installerImageArgs := core.MakeInstallerImageArgs{
32 TargetPath: args[0],
33 Installer: installer,
34 NodeParams: params,
35 Bundle: bundle,
36 }
37
38 log.Printf("Generating installer image (this can take a while, see issues/92).")
39 if err := core.MakeInstallerImage(installerImageArgs); err != nil {
40 log.Fatalf("Failed to create installer: %v", err)
41 }
42}
43
44func init() {
45 genusbCmd.Flags().StringP("installer", "i", "", "Path to the Metropolis installer to use when installing")
46 installCmd.AddCommand(genusbCmd)
47}