-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump patch: add os validation; refactor some code and put argument di…
…rectory_name to specify the installed odoo instance
- Loading branch information
1 parent
256c674
commit 7e197e3
Showing
6 changed files
with
117 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"odoo-one-click/cmd" | ||
"odoo-one-click/config" | ||
"odoo-one-click/utils" | ||
"os" | ||
"os/exec" | ||
"runtime" | ||
) | ||
|
||
func main() { | ||
// TODO: add validation to check if the OS is ubuntu or derivatives | ||
// on elementary, there is UPSTREAM lsb-release, but it seemms not on all derivatives | ||
// OS Check, for now it's only for ubuntu and derivatives | ||
if runtime.GOOS != "linux" { | ||
fmt.Println("This program only works on Ubuntu or derivatives") | ||
os.Exit(1) | ||
} else { | ||
// Check if UBUNTU_CODENAME is on allowedOS | ||
if err := checkOSVersion(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
cmd.Execute() | ||
} | ||
|
||
func checkOSVersion() error { | ||
out, err := exec.Command("bash", "-c", "source /etc/os-release; echo $UBUNTU_CODENAME").Output() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// check if UBUNTU_CODENAME on allowedOS | ||
codename := utils.RemoveNewLine(string(out)) | ||
if !config.IsAllowedOS(codename) { | ||
return fmt.Errorf("ubuntu version is not supported") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters