-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
76 lines (74 loc) · 1.75 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"Magic-Stick-Creator/config"
"Magic-Stick-Creator/core"
"Magic-Stick-Creator/generate"
"fmt"
"os"
"time"
)
func main() {
var action string
var version int = 1
if core.Exists("config.plist") {
var mod int
var ac string
fmt.Printf("监测到存在plist,是否进行三码迁移(若plist中没有3码谨慎操作)[Y/n]")
fmt.Scan(&ac)
if ac == "y" || ac == "Y" {
fmt.Println("请选择你的plist版本")
fmt.Println("1.Clover")
fmt.Println("2.OC")
fmt.Scan(&mod)
if mod <= 0 || mod > 2 {
fmt.Println("选择错误")
} else {
core.ChangeSN(mod)
}
}
fmt.Println("退出三码三码转移")
}
fmt.Println("请选择你需要下载镜像的版本")
for i, v := range config.Select {
fmt.Println(i, v.Vs)
}
fmt.Scan(&version)
if version < 0 || version > len(config.Select)-1 {
panic("版本选择错误")
} else {
fmt.Printf("需要先下载约500MB的Recovery镜像,是否开始? [Y/n]")
fmt.Scan(&action)
if action == "Y" || action == "y" {
if core.Exists(config.Path) {
os.Remove(config.Path)
}
os.Mkdir(config.Path, 0755)
fmt.Println("选择了" + config.Select[version].Vs + "版本...")
core.Download_image(generate.Get_image_info(config.Select[version]))
Add_Details()
fmt.Println("镜像下载完成")
} else {
fmt.Println("中止安装")
return
}
}
fmt.Println("将在3秒后自动退出")
time.Sleep(3 * 1e9)
}
func Add_Details() {
fileName := ".contentDetails"
if core.Exists(fileName) {
err := os.Remove(fileName)
if err != nil {
panic(err)
}
}
dstFile, err := os.Create(config.Path + "/" + fileName)
if err != nil {
fmt.Println(err.Error())
return
}
defer dstFile.Close()
s := "macOS Boot From Recovery"
dstFile.WriteString(s)
}