abra/cli/upgrade.go

45 lines
1.2 KiB
Go
Raw Normal View History

2021-09-07 13:23:10 +00:00
package cli
import (
2021-12-19 15:06:07 +00:00
"fmt"
2021-09-07 13:23:10 +00:00
"os/exec"
"coopcloud.tech/abra/cli/internal"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
2021-12-19 15:06:07 +00:00
var mainURL = "https://install.abra.coopcloud.tech"
var releaseCandidateURL = "https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer"
2021-09-07 13:23:10 +00:00
// UpgradeCommand upgrades abra in-place.
var UpgradeCommand = &cli.Command{
Name: "upgrade",
2021-12-19 23:49:54 +00:00
Usage: "Upgrade Abra",
2021-12-19 15:06:22 +00:00
Description: `
This command allows you to upgrade Abra in-place with the latest stable or
release candidate.
If you would like to install the latest release candidate, please pass the
"--rc" option. Please bear in mind that the latest release candidate may have
some catastrophic bugs contained in it. In any case, thank you very much for
testing efforts!
`,
2021-12-19 15:00:16 +00:00
Flags: []cli.Flag{internal.RCFlag},
2021-09-07 13:23:10 +00:00
Action: func(c *cli.Context) error {
2021-12-19 15:06:07 +00:00
cmd := exec.Command("bash", "-c", fmt.Sprintf("curl -s %s | bash", mainURL))
2021-12-19 15:00:16 +00:00
if internal.RC {
2021-12-19 15:06:07 +00:00
cmd = exec.Command("bash", "-c", fmt.Sprintf("curl -s %s | bash -s -- --rc", releaseCandidateURL))
2021-11-13 16:34:20 +00:00
}
2021-12-19 15:08:28 +00:00
logrus.Debugf("attempting to run '%s'", cmd)
2021-12-19 15:08:28 +00:00
2021-09-07 13:23:10 +00:00
if err := internal.RunCmd(cmd); err != nil {
logrus.Fatal(err)
}
2021-12-19 15:08:28 +00:00
2021-09-07 13:23:10 +00:00
return nil
},
}