-
Notifications
You must be signed in to change notification settings - Fork 0
/
tuna.ipxe
247 lines (219 loc) · 10.7 KB
/
tuna.ipxe
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!ipxe
set os exit
set main-menu-timeout 5000
set arch unknown
iseq ${buildarch} arm64 && set arch arm64 ||
iseq ${buildarch} i386 && set arch intel ||
iseq ${buildarch} x86_64 && set arch intel ||
iseq ${arch} intel && set linux-arch amd64 ||
iseq ${arch} arm64 && set linux-arch arm64 ||
:main-menu
menu --name main Please choose an OS
item --menu main --gap ******************** WARNING *******************
item --menu main --gap * This PXE system is for system installation ${} ${} *
item --menu main --gap * or repairing. Misuse can lead to PERMANENT ${} ${} *
item --menu main --gap * DATA LOSS. Use with care. ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} ${} *
item --menu main --gap ************************************************
item --menu main --gap If you cannot understand, do NOTHING and exit.
iseq ${arch} unknown || item --menu main debian Debian, Ubuntu
iseq ${arch} unknown || item --menu main rhel CentOS
iseq ${arch} intel && item --menu main win Windows ||
item --menu main exit Continue Normal Boot
choose --menu main --default ${os} --timeout ${main-menu-timeout} os || goto exit
set mirror-proto http
set mirror-host mirrors.tuna.tsinghua.edu.cn
set mirror-url ${mirror-proto}://${mirror-host}
set kernel-append
set linux-rescue false
set linux-cmdline disabled
set main-menu-timeout 0
goto ${os}
:debian
set deb-release debian
set deb-secure-opt apt-setup/security_host=debian-security.tuna.tsinghua.edu.cn
set deb-dist buster
set deb-arch amd64
set deb-firm disabled
:debian-chooser
set deb-arch ${linux-arch}
menu --name debian-chooser Install or Rescue a Debian System
item --menu debian-chooser debian-choose-release Release: ${deb-release}
item --menu debian-chooser debian-choose-dist Version: ${deb-dist}
item --menu debian-chooser linux-choose-arch Architecture: ${deb-arch}
item --menu debian-chooser linux-choose-rescue Rescue a Broken System: ${linux-rescue}
item --menu debian-chooser debian-boot --> Boot Selected System <--
item --menu debian-chooser main-menu Go Back
item --menu debian-chooser --gap *************** Advanced Settings ***************
item --menu debian-chooser debian-choose-firmware Load Additional Firmwares: ${deb-firm}
item --menu debian-chooser --gap Enable the above setting when network interfaces cannot be identified.
item --menu debian-chooser linux-choose-cmdline Enter iPXE Command Line Before Booting: ${linux-cmdline}
item --menu debian-chooser linux-set-append Additional Kernel Options (Advanced): ${kernel-append}
choose --menu debian-chooser --default ${debian-chooser-edit-option} debian-chooser-edit-option || goto main-menu
goto ${debian-chooser-edit-option}
:debian-choose-release
menu --name debian-choose-release Release
item --menu debian-choose-release debian Debian
item --menu debian-choose-release ubuntu Ubuntu
choose --menu debian-choose-release --default ${deb-release} deb-release-new ||
iseq ${deb-release} ${deb-release-new} && goto debian-choose-release-change-no ||
goto debian-choose-release-change-${deb-release-new}
:debian-choose-release-change-debian
set deb-dist buster
set deb-secure-opt apt-setup/security_host=debian-security.tuna.tsinghua.edu.cn
goto debian-choose-release-change-no
:debian-choose-release-change-ubuntu
set deb-dist bionic
set deb-secure-opt apt-setup/security_host=${mirror-host} apt-setup/security_path=/ubuntu
iseq ${linux-arch} arm64 && set deb-secure-opt ${deb-secure-opt}-ports ||
goto debian-choose-release-change-no
:debian-choose-release-change-no
set deb-release ${deb-release-new}
goto debian-chooser
:debian-choose-dist
goto debian-choose-dist-${deb-release}
:debian-choose-dist-debian
menu --name debian-choose-dist-debian Debian Versions
item --menu debian-choose-dist-debian buster Debian Buster 10
item --menu debian-choose-dist-debian stretch Debian Stretch 9
iseq ${linux-arch} arm64 || item --menu debian-choose-dist-debian jessie Debian Jessie 8
choose --menu debian-choose-dist-debian --default ${deb-dist} deb-dist ||
goto debian-chooser
:debian-choose-dist-ubuntu
menu --name debian-choose-dist-ubuntu Ubuntu Versions
item --menu debian-choose-dist-ubuntu focal Ubuntu Focal 20.04
item --menu debian-choose-dist-ubuntu bionic Ubuntu Bionic 18.04
item --menu debian-choose-dist-ubuntu xenial Ubuntu Xenial 16.04
iseq ${linux-arch} arm64 || item --menu debian-choose-dist-ubuntu trusty Ubuntu Trusty 14.04
choose --menu debian-choose-dist-ubuntu --default ${deb-dist} deb-dist ||
goto debian-chooser
:debian-choose-firmware
menu --name debian-choose-firmware Load Additional Firmwares
item --menu debian-choose-firmware disabled Disabled
item --menu debian-choose-firmware enabled Enabled
choose --menu debian-choose-firmware --default ${deb-firm} deb-firm ||
goto debian-chooser
:rhel
set rhel-release centos
set rhel-dist 8
set rhel-text false
:rhel-chooser
iseq ${linux-arch} amd64 && set rhel-arch x86_64 ||
iseq ${linux-arch} i386 && set rhel-arch i386 ||
iseq ${linux-arch} arm64 && set rhel-arch aarch64 ||
iseq ${rhel-release}-${rhel-dist} centos-8 && set rhel-base-url ${rhel-dist}/BaseOS/${rhel-arch}/os || set rhel-base-url ${rhel-dist}/os/${rhel-arch}
menu --name rhel-chooser Install or Rescue a CentOS System
item --menu rhel-chooser rhel-choose-release Release: ${rhel-release}
item --menu rhel-chooser rhel-choose-dist Version: ${rhel-dist}
item --menu rhel-chooser linux-choose-arch Architecture: ${rhel-arch}
item --menu rhel-chooser linux-choose-rescue Rescue a Broken System: ${linux-rescue}
item --menu rhel-chooser rhel-choose-text Text Mode: ${rhel-text}
item --menu rhel-chooser rhel-boot --> Boot Selected System <--
item --menu rhel-chooser main-menu Go Back
item --menu rhel-chooser --gap *************** Advanced Settings ***************
item --menu rhel-chooser linux-choose-cmdline Enter iPXE Command Line Before Booting: ${linux-cmdline}
item --menu rhel-chooser linux-set-append Additional Kernel Options (Advanced): ${kernel-append}
choose --menu rhel-chooser --default ${rhel-chooser-edit-option} rhel-chooser-edit-option || goto main-menu
goto ${rhel-chooser-edit-option}
:rhel-choose-release
menu --name rhel-choose-release Release
item --menu rhel-choose-release centos CentOS
choose --menu rhel-choose-release --default ${rhel-release} rhel-release-new ||
iseq ${rhel-release} ${rhel-release-new} && goto rhel-choose-release-change-no ||
goto rhel-choose-release-change-${rhel-release-new}
:rhel-choose-release-change-centos
set rhel-dist 8
goto rhel-choose-release-change-no
:rhel-choose-release-change-no
set rhel-release ${rhel-release-new}
goto rhel-chooser
:rhel-choose-dist
goto rhel-choose-dist-${rhel-release}
:rhel-choose-dist-centos
menu --name rhel-choose-dist-centos CentOS Versions
item --menu rhel-choose-dist-centos 8 CentOS 8
item --menu rhel-choose-dist-centos 7 CentOS 7
iseq ${arch} arm64 || item --menu rhel-choose-dist-centos 6 CentOS 6
choose --menu rhel-choose-dist-centos --default ${rhel-dist} rhel-dist ||
goto rhel-chooser
:rhel-choose-text
menu --name rhel-choose-text Text Mode
item --menu rhel-choose-text false Disabled, Using GUI
item --menu rhel-choose-text true Enabled, Using TUI
choose --menu rhel-choose-text --default ${rhel-text} rhel-text ||
goto rhel-chooser
:win
set net0/next-server 0.0.0.0
imgexec tftp://${net0/next-server}/\boot\x86\wdsnbp.com
:exit
exit
:linux-set-append
echo -n Kernel command line: ${}
read kernel-append ||
goto ${os}-chooser
:linux-choose-arch
goto linux-choose-arch-${arch}
:linux-choose-arch-intel
menu --name linux-choose-arch Architecture
item --menu linux-choose-arch amd64 x86-64
iseq ${os}-${rhel-release}-${rhel-dist} rhel-centos-7 && goto linux-choose-arch-skip-i386 ||
iseq ${os}-${rhel-release}-${rhel-dist} rhel-centos-8 && goto linux-choose-arch-skip-i386 ||
iseq ${platform} efi && item --menu linux-choose-arch --gap x86 (Unavailable in EFI) || item --menu linux-choose-arch i386 x86
:linux-choose-arch-skip-i386
choose --menu linux-choose-arch --default ${linux-arch} linux-arch ||
goto ${os}-chooser
:linux-choose-arch-arm64
menu --name linux-choose-arch Architecture
item --menu linux-choose-arch arm64 AArch64
choose --menu linux-choose-arch --default ${linux-arch} linux-arch ||
goto ${os}-chooser
:linux-choose-rescue
menu --name linux-choose-rescue Rescue a Broken System
item --menu linux-choose-rescue false No
item --menu linux-choose-rescue true Yes
choose --menu linux-choose-rescue --default ${linux-rescue} linux-rescue ||
goto ${os}-chooser
:linux-choose-cmdline
menu --name linux-choose-cmdline Enter iPXE Command Line Before Booting
item --menu linux-choose-cmdline disabled Disabled
item --menu linux-choose-cmdline enabled Enabled
choose --menu linux-choose-cmdline --default ${linux-cmdline} linux-cmdline ||
goto ${os}-chooser
:debian-boot
imgfree ||
set deb-release-url ${deb-release}
set deb-legacy-images images
iseq ${os}-${deb-release}-${deb-dist} debian-ubuntu-focal && set deb-legacy-images legacy-images ||
iseq ${os}-${deb-release}-${deb-arch} debian-ubuntu-arm64 && set deb-release-url ${deb-release-url}-ports ||
set deb-base-dir ${mirror-url}/${deb-release-url}/dists/${deb-dist}/main/installer-${deb-arch}/current/${deb-legacy-images}/netboot/${deb-release}-installer/${deb-arch}
set deb-kernel-append-fw
iseq ${deb-firm} enabled || goto debian-boot-skip-fw
initrd ${mirror-url}/debian-nonfree/firmware/stable/current/firmware.cpio.gz ||
set deb-kernel-append-fw initrd=firmware.cpio.gz
:debian-boot-skip-fw
kernel ${deb-base-dir}/linux initrd=initrd.gz ${deb-kernel-append-fw} mirror/country=manual mirror/protocol=${mirror-proto} mirror/${mirror-proto}/hostname=${mirror-host} mirror/${mirror-proto}/directory=/${deb-release-url} mirror/${mirror-proto}/proxy= rescue/enable=${linux-rescue} ${deb-secure-opt} ${kernel-append} || goto linux-boot-failed
initrd ${deb-base-dir}/initrd.gz || goto linux-boot-failed
goto linux-boot
:rhel-boot
imgfree ||
set rhel-release-url ${rhel-release}
iseq ${os}-${rhel-release}-${rhel-dist}-${rhel-arch} rhel-centos-7-aarch64 && set rhel-release-url ${rhel-release-url}-altarch ||
set rhel-base ${mirror-url}/${rhel-release-url}/${rhel-base-url}
set rhel-base-dir ${rhel-base}/images/pxeboot
set rhel-kernel-append method=${rhel-base}/
iseq ${linux-rescue} true && set rhel-kernel-append ${rhel-kernel-append} rescue ||
iseq ${rhel-text} true && set rhel-kernel-append ${rhel-kernel-append} text ||
kernel ${rhel-base-dir}/vmlinuz initrd=initrd.img ${rhel-kernel-append} ${kernel-append} || goto linux-boot-failed
initrd ${rhel-base-dir}/initrd.img || goto linux-boot-failed
goto linux-boot
:linux-boot
iseq ${linux-cmdline} enabled || goto linux-boot-enter
echo This iPXE shell is for debug purposes.
echo Currently loaded images:
imgstat
echo Use exit to continue boot
shell
:linux-boot-enter
boot || goto linux-boot-failed
:linux-boot-failed
prompt Boot failed. Press enter to go back.
goto ${os}-chooser