-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.go
42 lines (37 loc) · 1.02 KB
/
verify.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
package workbench
import (
"fmt"
"os/exec"
"github.com/sol-eng/wbi/internal/system"
)
// Checks if Workbench is installed
func VerifyWorkbench() bool {
cmd := exec.Command("/bin/sh", "-c", "rstudio-server version")
stdout, err := cmd.Output()
if err != nil {
return false
} else {
system.PrintAndLogInfo("\nWorkbench installation detected: " + string(stdout))
return true
}
}
// Runs verify-installation command
func VerifyInstallation(username string) error {
// stop rstudio-server
err := StopRStudioServer()
if err != nil {
return fmt.Errorf("issue stopping rstudio-server: %w", err)
}
// run verify-installation
verifyCommand := "rstudio-server verify-installation --verify-user=" + username
err = system.RunCommand(verifyCommand, true, 1, false)
if err != nil {
return fmt.Errorf("issue running verify-installation command '%s': %w", verifyCommand, err)
}
// start rstudio-server
err = StartRStudioServer()
if err != nil {
return fmt.Errorf("issue starting rstudio-server: %w", err)
}
return nil
}