-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (42 loc) · 1.11 KB
/
main.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 main
import (
"fmt"
"odoo-one-click/cmd"
"odoo-one-click/config"
"odoo-one-click/utils"
"os"
"os/exec"
"runtime"
)
func main() {
// OS Check, for now it's only for ubuntu and derivatives
if runtime.GOOS == "linux" {
// Check if UBUNTU_CODENAME is on allowedOS
if err := checkOSVersion(); err != nil {
fmt.Println(err)
os.Exit(1)
}
} else if runtime.GOOS == "darwin" {
} else {
fmt.Println("This application only works on Ubuntu or derivatives")
os.Exit(1)
}
cmd.Execute()
}
func checkOSVersion() error {
skipUbuntuCheck := os.Getenv("SKIP_UBUNTU_CHECK")
if skipUbuntuCheck != "" {
return nil
}
// Continue to check the OS list when there is no skip ubuntu check
out, err := exec.Command("bash", "-c", "source /etc/os-release; echo $UBUNTU_CODENAME").Output()
if err != nil {
return err
}
// check if UBUNTU_CODENAME is n allowedOS
codename := utils.RemoveNewLine(string(out))
if !config.IsAllowedOS(codename) {
return fmt.Errorf("ubuntu version is not supported\nIf it's a mistakes, try to run the app again with\nenv SKIP_UBUNTU_CHECK=YES odoo-one-click")
}
return nil
}