-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.go
50 lines (41 loc) · 1004 Bytes
/
install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package app
import (
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/longhorn/cli/pkg/installer"
"github.com/longhorn/cli/pkg/pkgmgr"
)
func PreflightInstallCmd(pkgMgrType pkgmgr.PackageManagerType) cli.Command {
return cli.Command{
Name: "install",
Flags: []cli.Flag{},
Usage: "Install and configure prerequisites",
Action: func(c *cli.Context) {
if err := install(c, pkgMgrType); err != nil {
logrus.WithError(err).Fatalf("Failed to run command")
}
},
}
}
func install(_ *cli.Context, pkgMgrType pkgmgr.PackageManagerType) error {
ins, err := installer.NewInstaller(pkgMgrType)
if err != nil {
return err
}
if os.Getenv("UPDATE_PACKAGE_LIST") == "true" {
ins.UpdatePackageList()
}
ins.StartServices()
ins.ProbeModules(false)
ins.InstallPackages(false)
if os.Getenv("ENABLE_SPDK") == "true" {
ins.InstallPackages(true)
ins.ProbeModules(true)
err := ins.ConfigureSPDKEnv()
if err != nil {
return err
}
}
return nil
}