-
Notifications
You must be signed in to change notification settings - Fork 6
/
util.go
54 lines (46 loc) · 1.07 KB
/
util.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
51
52
53
54
package main
import (
"fmt"
"io/ioutil"
"log"
"net/url"
"os/exec"
"strings"
)
func validateAPIURL(apiURL string) error {
url, err := url.Parse(apiURL)
if err != nil {
return err
}
if url.Scheme == "" {
return fmt.Errorf("Scheme is no set in URL: %s", apiURL)
}
return nil
}
func isMounted(mountPath string) bool {
content, err := ioutil.ReadFile("/proc/mounts")
if err != nil {
log.Println(err)
}
for _, mount := range strings.Split(string(content), "\n") {
splitted := strings.Split(mount, " ")
if len(splitted) < 2 {
continue
}
if !strings.HasPrefix(splitted[0], "quobyte") {
continue
}
if splitted[1] == mountPath {
log.Printf("Found Mountpoint: %s\n", mountPath)
return true
}
}
return false
}
func mountAll(mountQuobyteOptions, quobyteRegistry, mountQuobytePath string) {
cmdStr := fmt.Sprintf("mount %s -t quobyte %s %s", mountQuobyteOptions, fmt.Sprintf("%s/", quobyteRegistry), mountQuobytePath)
if out, err := exec.Command("/bin/sh", "-c", cmdStr).CombinedOutput(); err != nil {
log.Println(err)
log.Fatalln(string(out))
}
}