forked from coop-cloud/abra
fix: use wget, error out on missing deps
See coop-cloud/organising#280.
This commit is contained in:
parent
48c965bb21
commit
0dc8425a27
|
@ -117,7 +117,17 @@ func installDockerLocal(c *cli.Context) error {
|
|||
logrus.Fatal("exiting as requested")
|
||||
}
|
||||
|
||||
cmd := exec.Command("bash", "-c", "curl -s https://get.docker.com | bash")
|
||||
for _, exe := range []string{"wget", "bash"} {
|
||||
exists, err := ensureLocalExecutable(exe)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("%s missing, please install it", exe)
|
||||
}
|
||||
}
|
||||
|
||||
cmd := exec.Command("bash", "-c", "wget -O- https://install.abra.coopcloud.tech | bash")
|
||||
if err := internal.RunCmd(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -136,15 +146,17 @@ func newLocalServer(c *cli.Context, domainName string) error {
|
|||
}
|
||||
|
||||
if provision {
|
||||
out, err := exec.Command("which", "docker").Output()
|
||||
exists, err := ensureLocalExecutable("docker")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if string(out) == "" {
|
||||
|
||||
if !exists {
|
||||
if err := installDockerLocal(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := initSwarmLocal(c, cl, domainName); err != nil {
|
||||
if !strings.Contains(err.Error(), "proxy already exists") {
|
||||
logrus.Fatal(err)
|
||||
|
@ -195,12 +207,12 @@ func newClient(c *cli.Context, domainName string) (*dockerClient.Client, error)
|
|||
}
|
||||
|
||||
func installDocker(c *cli.Context, cl *dockerClient.Client, sshCl *ssh.Client, domainName string) error {
|
||||
result, err := sshCl.Exec("which docker")
|
||||
if err != nil && string(result) != "" {
|
||||
exists, err := ensureRemoteExecutable("docker", sshCl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if string(result) == "" {
|
||||
if !exists {
|
||||
fmt.Println(fmt.Sprintf(dockerInstallMsg, domainName))
|
||||
|
||||
response := false
|
||||
|
@ -214,7 +226,17 @@ func installDocker(c *cli.Context, cl *dockerClient.Client, sshCl *ssh.Client, d
|
|||
logrus.Fatal("exiting as requested")
|
||||
}
|
||||
|
||||
cmd := "curl -s https://get.docker.com | bash"
|
||||
for _, exe := range []string{"wget", "bash"} {
|
||||
exists, err := ensureRemoteExecutable(exe, sshCl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("%s missing on remote, please install it", exe)
|
||||
}
|
||||
}
|
||||
|
||||
cmd := "wget -O- https://install.abra.coopcloud.tech | bash"
|
||||
|
||||
var sudoPass string
|
||||
if askSudoPass {
|
||||
|
@ -485,3 +507,23 @@ You may omit flags to avoid performing this provisioning logic.
|
|||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// ensureLocalExecutable ensures that an executable is present on the local machine
|
||||
func ensureLocalExecutable(exe string) (bool, error) {
|
||||
out, err := exec.Command("which", exe).Output()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return string(out) == "", nil
|
||||
}
|
||||
|
||||
// ensureRemoteExecutable ensures that an executable is present on a remote machine
|
||||
func ensureRemoteExecutable(exe string, sshCl *ssh.Client) (bool, error) {
|
||||
out, err := sshCl.Exec(fmt.Sprintf("which %s", exe))
|
||||
if err != nil && string(out) != "" {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return string(out) == "", nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue