This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
myefi.sh
153 lines (147 loc) · 3.18 KB
/
myefi.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
cwd=$(dirname $0)
config=$cwd/OC/config.plist
config4k=$cwd/OC/config_4k.plist
backup_path=~/UUID-Backup
getUUID(){
if test ! -f $backup_path/$1;then
echo null
return
fi
echo `cat $backup_path/$1`
}
getValue(){
if test ! -f $config;then
echo "config 文件不存在"
return
fi
p=`grep -n "<key>$1</key>" $config|head -n 1|cut -d ':' -f1`
let p=p+1
value=`sed "${p}q;d" $config|sed "s#$(echo '\t')\+>##"`
value=`echo $value|sed "s#<##"|sed "s#/>##"`
if [[ $value == true || $value == false ]]; then
echo $value
return
fi
value=`echo $value|sed "s#<.*>##"|sed "s#.*>##"`
echo $value
}
setValue(){
p=`grep -n "<key>$1</key>" $config|head -n 1|cut -d ':' -f1`
let p=p+1
sed -i "" "${p}s#<.*>#$2#" $config
}
mlb=`getUUID MLB`
rom=`getUUID ROM`
ssn=`getUUID SystemSerialNumber`
uuid=`getUUID SystemUUID`
usage(){
echo "
$0 <make|reset_uuid|clear_uuid|push|rmf(remove_macos_files)> [extra arguments...]
"
}
change_config(){
if test -z $1;then
echo "less than 1 arguments"
exit 1
fi
/usr/bin/sed -i "" "s/$1/$2/g" $config
}
reset_uuid(){
setValue MLB "<string>${mlb}</string>"
setValue ROM "<data>${rom}</data>"
setValue SystemSerialNumber "<string>${ssn}</string>"
setValue SystemUUID "<string>${uuid}</string>"
echo "UUID 已恢复"
}
clear_uuid(){
remove_macos_files
setValue MLB "<string>000000000000000000000</string>"
setValue ROM "<data>00000000</data>"
setValue SystemSerialNumber "<string>000000000000</string>"
setValue SystemUUID "<string>00000000-0000-0000-0000-000000000000</string>"
echo "UUID 已清除"
}
enable_4k(){
echo "为 4K 屏幕设置参数"
setValue dpcd-max-link-rate "<data>FAAAAA==</data>"
setValue UIScale "<data>Ag==</data>"
}
disable_4k(){
echo "为 1080P 屏幕设置参数"
setValue dpcd-max-link-rate "<data>CgAAAA==</data>"
setValue UIScale "<data>AQ==</data>"
}
enable_picker(){
echo "启用 ShowPicker"
setValue ShowPicker "<true/>"
setValue Timeout "<integer>5</integer>"
}
disable_picker(){
echo "禁用 ShowPicker"
setValue ShowPicker "<false/>"
setValue Timeout "<integer>0</integer>"
}
usemy(){
echo "恢复我的配置文件"
cp -f $config4k $config
rm -f $config4k
enable_4k
disable_picker
reset_uuid
}
autoconfig(){
clear_uuid
cp -f $config $config4k
echo "已生成 4K屏 配置文件\t: $config4k"
disable_4k
enable_picker
echo "已生成 1080P屏 配置文件\t: $config"
}
make(){
if test -z "$1";then
echo "指定输出文件名"
exit 1
fi
autoconfig
remove_macos_files
cd ..
zip -qr "$1" EFI/BOOT EFI/OC EFI/附加工具 EFI/README.md
cd - >/dev/null
usemy
}
push(){
if test -z "$2";then
echo "less than 2 arguments"
exit 1
fi
remove_macos_files
autoconfig
git checkout "$2"
git add .
git commit -m "$1"
git push -u origin "$2"
usemy
}
remove_macos_files(){
find "$cwd/.." -name "._*" -exec rm -rf {} \;
}
if test -z $1;then
usage
elif [[ "$1"x == "clear_uuid"x ]];then
clear_uuid
elif [[ "$1"x == "reset_uuid"x ]];then
reset_uuid
elif [[ "$1"x == "make"x ]];then
make "$2"
elif [[ "$1"x == "push"x ]];then
push "$2" OpenCore
elif [[ "$1"x == "push-dev"x ]];then
push "$2" dev
elif [[ "$1"x == "stash"x ]];then
autoconfig
elif [[ "$1"x == "unstash"x ]];then
usemy
elif [[ "$1"x == "rmf"x ]];then
remove_macos_files
fi