-
-
Notifications
You must be signed in to change notification settings - Fork 716
/
Copy pathnetboot.xyz.j2
143 lines (126 loc) · 5.01 KB
/
netboot.xyz.j2
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
#!ipxe
set esc:hex 1b
set bold ${esc:string}[1m
set boldoff ${esc:string}[22m
set fg_gre ${esc:string}[32m
set fg_cya ${esc:string}[36m
set fg_whi ${esc:string}[37m
set VARS_ERR Local vars file not found... attempting TFTP boot...
set TFTP_ERR Local TFTP failed... attempting remote HTTPS
set V6_ERR IPv6 appears to have failed... attempting IPv4...
set HTTPS_ERR HTTPS appears to have failed... attempting HTTP
set HTTP_ERR HTTP has failed, localbooting...
set site_name {{ site_name }}
set boot_domain {{ boot_domain }}
set ipxe_version ${version}
set version {{ boot_version }}
set conn_type https
:start
echo ${bold}${fg_gre}${site_name} - ${fg_whi}v${version}${boldoff}
iseq ${site_name} netboot.xyz || echo ${bold}${fg_whi}Powered by ${fg_gre}netboot.xyz${fg_whi}${boldoff}
prompt --key m --timeout 4000 Hit the ${bold}m${boldoff} key to open failsafe menu... && goto failsafe || goto dhcp
:dhcp
echo
dhcp || goto netconfig
isset ${next-server} && isset ${proxydhcp/next-server} && goto choose-tftp || set tftp-server ${next-server} && goto load-custom-ipxe
:choose-tftp
# Load "proxy settings" from root server
chain tftp://${next-server}/local-vars.ipxe || echo ${VARS_ERR}
# Check if the proxy-dhcp-vars script has made any usable command about how to progress with a next-server and a proxy-next-server being set
isset ${use_proxydhcp_settings} && iseq ${use_proxydhcp_settings} true && goto set-next-server ||
prompt --key p --timeout 4000 DHCP proxy detected, press ${bold}p${boldoff} to boot from ${proxydhcp/next-server}... && set use_proxydhcp_settings true || set use_proxydhcp_settings false
goto set-next-server
:set-next-server
iseq ${use_proxydhcp_settings} true && set tftp-server ${proxydhcp/next-server} || set tftp-server ${next-server}
goto load-custom-ipxe
:load-custom-ipxe
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}.kpxe && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-undionly.kpxe && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-snp.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-snponly.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-arm64.efi && goto tftpmenu ||
goto menu
:failsafe
menu ${boot_domain} Failsafe Menu
item localboot Boot to local drive
item netconfig Manual network configuration
item vlan Manual VLAN configuration
item retry Retry boot
item debug iPXE Debug Shell
item reboot Reboot System
choose failsafe_choice || exit
goto ${failsafe_choice}
:netconfig
echo Network Configuration:
echo Available interfaces...
ifstat
imgfree
echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
isset ${net} || set net 0
echo -n IP: && read net${net}/ip
echo -n Subnet mask: && read net${net}/netmask
echo -n Gateway: && read net${net}/gateway
echo -n DNS: && read dns
ifopen net${net}
echo Attempting chainload of ${boot_domain}...
goto menu || goto failsafe
:vlan
echo VLAN Configuration:
echo Available interfaces...
ifstat
imgfree
echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
isset ${net} || set net 0
echo -n Set VLAN 802.1Q tag [0 to 4094]: ${} && read vlan
vcreate --tag ${vlan} net${net}
ifconf --configurator dhcp net${net}-${vlan} || echo DHCP failed trying manual && goto netvlan
echo Attempting chainload of ${boot_domain}...
goto menu || goto failsafe
:netvlan
echo -n IP: && read net${net}-${vlan}/ip
echo -n Subnet mask: && read net${net}-${vlan}/netmask
echo -n Gateway: && read net${net}-${vlan}/gateway
echo -n DNS: && read dns
ifopen net${net}-${vlan}
echo Attempting chainload of ${boot_domain}...
goto menu || goto failsafe
:tftpmenu
chain tftp://${tftp-server}/local-vars.ipxe || echo ${VARS_ERR}
isset ${hostname} && chain --autofree tftp://${tftp-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
chain --autofree tftp://${tftp-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC not found booting default...
chain --autofree tftp://${tftp-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
:menu
{% if bootloader_https_enabled | bool %}
:menu_https
set conn_type https
goto menu_start
{% endif %}
{% if bootloader_http_enabled | bool %}
:menu_http
set conn_type http
goto menu_start
{% endif %}
:menu_start
isset ${netX/dns6} && goto menu_v6 || goto menu_v4
:menu_v6
isset ${netX/dns6_bak} && set netX/dns6 ${netX/dns6_bak} ||
set netX/dns6_bak ${netX/dns6}
echo Attempting ${conn_type} boot over IPv6...
chain --autofree ${conn_type}://${boot_domain}/menu.ipxe || echo ${conn_type} IPv6 failed... attempting IPv4...
clear netX/dns6
:menu_v4
echo Attempting ${conn_type} boot over IPv4...
chain --autofree ${conn_type}://${boot_domain}/menu.ipxe || echo ${conn_type} IPv4 failed...
iseq ${conn_type} https && goto menu_http || goto localboot
:localboot
exit
:retry
goto start
:reboot
reboot
goto start
:debug
echo Type "exit" to return to menu
shell
goto failsafe