MCPcopy Create free account
hub / github.com/danderson/netboot / ubuntuRecipe

Function ubuntuRecipe

pixiecore/cli/quickcmd.go:90–148  ·  view source on GitHub ↗
(parent *cobra.Command)

Source from the content-addressed store, hash-verified

88}
89
90func ubuntuRecipe(parent *cobra.Command) {
91 versions := []string{
92 "precise",
93 "trusty",
94 "xenial",
95 "bionic",
96 "cosmic",
97 "disco",
98 "eoan",
99 "focal",
100 "groovy",
101 }
102
103 ubuntuCmd := &cobra.Command{
104 Use: "ubuntu version",
105 Short: "Boot an Ubuntu installer",
106 Long: fmt.Sprintf("Boot an Ubuntu installer for the given version (one of %s)", strings.Join(versions, ",")),
107 Run: func(cmd *cobra.Command, args []string) {
108 if len(args) < 1 {
109 fatalf("you must specify an Ubuntu version")
110 }
111 var version string
112 for _, v := range versions {
113 if args[0] == v {
114 version = v
115 break
116 }
117 }
118 if version == "" {
119 fatalf("Unknown Ubuntu version %q", version)
120 }
121
122 arch, err := cmd.Flags().GetString("arch")
123 if err != nil {
124 fatalf("Error reading flag: %s", err)
125 }
126 mirror, err := cmd.Flags().GetString("mirror")
127 if err != nil {
128 fatalf("Error reading flag: %s", err)
129 }
130
131 imageDir := "images"
132 if version[0] >= 'f' {
133 imageDir = "legacy-images"
134 }
135
136 kernel := fmt.Sprintf("%s/dists/%s/main/installer-%s/current/%s/netboot/ubuntu-installer/%s/linux", mirror, version, arch, imageDir, arch)
137 initrd := fmt.Sprintf("%s/dists/%s/main/installer-%s/current/%s/netboot/ubuntu-installer/%s/initrd.gz", mirror, version, arch, imageDir, arch)
138
139 fmt.Println(staticFromFlags(cmd, kernel, []string{initrd}, "").Serve())
140 },
141 }
142
143 ubuntuCmd.Flags().String("arch", "amd64", "CPU architecture of the Ubuntu installer files")
144 ubuntuCmd.Flags().String("mirror", "https://mirrors.kernel.org/ubuntu", "Root of the ubuntu mirror to use")
145 serverConfigFlags(ubuntuCmd)
146 staticConfigFlags(ubuntuCmd)
147 parent.AddCommand(ubuntuCmd)

Callers 1

initFunction · 0.85

Calls 6

staticFromFlagsFunction · 0.85
serverConfigFlagsFunction · 0.85
staticConfigFlagsFunction · 0.85
fatalfFunction · 0.70
ServeMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected