-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
70 lines (56 loc) · 1.68 KB
/
Copy pathmain.go
File metadata and controls
70 lines (56 loc) · 1.68 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"os"
"path/filepath"
"runtime"
foremanbuilder "github.com/aidenfine/foreman-builder/foreman-builder"
"github.com/aidenfine/foreman-builder/foreman-builder/cmd"
)
func main() {
if !isSystemSupported() {
os.Exit(1)
}
if !foremanbuilder.IsOrbStackRunning() {
foremanbuilder.Logger.Fatal("Orbstack must be running")
}
home, err := os.UserHomeDir()
if err != nil {
foremanbuilder.Logger.Fatalf("Failed to get home directory: %v", err)
}
dotFolderPath := filepath.Join(home, ".foreman-builder")
containersPath := filepath.Join(dotFolderPath, "containers")
dotfolderExists, err := foremanbuilder.DoesFileOrDirectoryExist(dotFolderPath)
if err != nil {
foremanbuilder.Logger.Errorf("Error checking dotfolder: %v", err)
}
containersExists, err := foremanbuilder.DoesFileOrDirectoryExist(containersPath)
if err != nil {
foremanbuilder.Logger.Errorf("Error checking containers file: %v", err)
}
if !dotfolderExists {
foremanbuilder.Logger.Info("Creating dotfolder...")
err := os.MkdirAll(dotFolderPath, 0755)
if err != nil {
foremanbuilder.Logger.Fatalf("Failed to create dotfolder: %v", err)
}
}
if !containersExists {
foremanbuilder.Logger.Info("Creating containers file...")
err := os.WriteFile(containersPath, []byte(""), 0644)
if err != nil {
foremanbuilder.Logger.Fatalf("Failed to create container file: %v", err)
}
}
cmd.SyncContainers()
cmd.Execute()
}
func isSystemSupported() bool {
// arm64 = silicon chip
// amd64 = non silicon chip
userCPU := runtime.GOARCH
if userCPU != "arm64" {
foremanbuilder.Logger.Fatal("foreman-builder does not currently support non apple-silicon devices!")
return false
}
return true
}