Skip to content

Commit

Permalink
Give notice of high sierra issues
Browse files Browse the repository at this point in the history
Resolves #620
  • Loading branch information
glinton committed Nov 30, 2017
1 parent 100a595 commit 13e8400
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
6 changes: 5 additions & 1 deletion main.go
Expand Up @@ -68,7 +68,11 @@ func main() {
// do the commands configure check here
command := strings.Join(os.Args, " ")
if _, err := models.LoadConfig(); err != nil && !strings.Contains(command, " config") && !strings.Contains(command, "env server") {
processors.Configure()
err = processors.Configure()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}

migrationCheck()
Expand Down
37 changes: 34 additions & 3 deletions processors/configure.go
Expand Up @@ -3,22 +3,51 @@ package processors
import (
"fmt"
"os"
"os/exec"
"runtime"
"time"

"github.com/nanobox-io/nanobox/models"
"github.com/nanobox-io/nanobox/util"
)

var configured bool

func Configure() error {
var os string

// make sure to only run configure one time
if configured {
return nil
}
configured = true

<-time.After(time.Second)
v, err := util.OsDetect()
if err == nil {
os = v
}

if os == "high sierra" {
// warn about high sierra
hasRead := stringAsker(`
--------------------------------------------------------------------------------
+ WARNING:
+
+ MacOS High Sierra introduces breaking changes to Nanobox!
+
+ Please ensure you have read the following guides before continuing:
+ https://content.nanobox.io/installing-nanobox-on-macos-high-sierra/
--------------------------------------------------------------------------------
Have you already read the guide? y/n`, map[string]string{"y": "yes", "n": "no"})
if hasRead == "no" {
exec.Command("open", "https://content.nanobox.io/installing-nanobox-on-macos-high-sierra/").Start()
return fmt.Errorf("\nEnding configure, please read the guide and try again.\n")
}
}

// todo: why do we wait?
<-time.After(150 * time.Millisecond)

config := &models.Config{
Provider: "docker-machine",
Expand Down Expand Up @@ -83,13 +112,15 @@ How many GB of RAM would you like to make available to the VM (2-4)?
Answer: `, 8)

// ask about mount types
config.MountType = stringAsker(`
if os != "high sierra" {
// ask about mount types
config.MountType = stringAsker(`
Would you like to enable netfs for faster filesystem access (y/n)?
-------------------------------------------------------------------
Note : We HIGHLY recommend (y). Using this option may prompt for password
Answer: `, map[string]string{"y": "netfs", "n": "native"})
}

config.Save()

Expand Down
46 changes: 46 additions & 0 deletions util/os.go
@@ -0,0 +1,46 @@
package util

import (
"fmt"
"os/exec"
"runtime"
"regexp"
)

func OsDetect() (string, error) {
switch runtime.GOOS {
case "darwin":
return getDarwin()
case "windows":
return "windows", nil
case "linux":
return "linux", nil
}

return "", fmt.Errorf("Unsupported operating system. Please contact support.")
}

func getDarwin() (string, error) {
out, err := exec.Command("/usr/bin/sw_vers", "-productVersion").Output()
if err != nil {
return "", fmt.Errorf("Failed to retrieve version - %s", err.Error())
}
r, _ := regexp.Compile("10\\.([0-9]+).*")
match := r.FindStringSubmatch(string(out))
if len(match) != 2 {
return "", fmt.Errorf("Failed to parse version")
}

return toDarwin(match[1])
}

func toDarwin(v string) (string, error) {
switch v {
case "12":
return "sierra", nil
case "13":
return "high sierra", nil
default:
return "incompatible", fmt.Errorf("Incompatible OSX version. Please contact support.")
}
}

0 comments on commit 13e8400

Please sign in to comment.