-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.ipxe
157 lines (137 loc) · 4.54 KB
/
link.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
#!ipxe
set esc:hex 1b
set term_color:hex 1b:5b:31:3b
set c_red ${term_color:string}31m
set c_green ${term_color:string}32m
set c_blue ${term_color:string}34m
set c_reset ${esc:string}[0m
echo ${c_reset}
echo ${c_green}boot${c_reset} - ${c_red}woa7's ${c_blue}boot menu${c_reset}
echo ${c_reset}
:start
#set boot_salstar_version 1
set boot_woa7_version 1
:link_retry
# try 2-times
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf || ifconf || goto link_menu
:boot
# FIXME # set base https://boot.salstar.sk/
# FIXME # set base_ip http://158.197.16.66/boot/
#set base https://woa7.github.io/boot/
#set base https://woa7.github.io/ipxe/
set base https://${next-server}/boot/
set base_ip http://${next-server}/boot/
# show address
echo IP: ${ip}, netmask: ${netmask}, gateway: ${gateway}
# try to sync date
ntp ${next-server} || ntp ntp.salstar.sk || ntp 0.openwrt.pool.ntp.org ||
:boot_chain
# allow loading of custom script set via DHCP server
# option site-local-128 code 128 = string;
# option site-local-128 "http://host.domain/filename";
isset ${128:string} && chain --autofree ${128:string} ||
chain --autofree ${base}by_mac/${mac} ||
chain --autofree ${base}by_ip/${ip} ||
chain --autofree --replace ${base}menu.ipxe && exit ||
:link_menu
prompt --timeout 20000 Press any key to enter failsafe menu ... || exit
menu Internal script failed!
item --key l exit Boot local hdd [l]
item --key n network Manual network configuration [n]
item --key v vlan Configure VLANs [v]
item --key c chain Chainload another iPXE [c]
item --key c chain_boot.salstar.sk Chainload boot.salstar.sk iPXE [C]
item --key r retry Retry [r]
item --key 4 retry4 Retry using IPv4 protocol only [4]
item --key b reboot Reboot [b]
item --key w reboot_warm Warm reboot [w]
item --key f boot_ip Fallback boot without DNS [f]
item --key s shell Start iPXE shell [s]
choose --timeout 60000 link_menu || exit
goto link_${link_menu}
:link_exit
exit
:link_network
echo Network configuration:
echo -n Enter network card number [0 for net0, defaults to 0]: ${}
read net
isset ${net} || set net 0
echo -n Enter IP address: ${}
read net${net}/ip
echo -n Enter netmask: ${}
read mask
iseq ${mask} 8 && set mask 255.0.0.0 ||
iseq ${mask} 9 && set mask 255.128.0.0 ||
iseq ${mask} 10 && set mask 255.192.0.0 ||
iseq ${mask} 11 && set mask 255.224.0.0 ||
iseq ${mask} 12 && set mask 255.240.0.0 ||
iseq ${mask} 13 && set mask 255.248.0.0 ||
iseq ${mask} 14 && set mask 255.252.0.0 ||
iseq ${mask} 15 && set mask 255.254.0.0 ||
iseq ${mask} 16 && set mask 255.255.0.0 ||
iseq ${mask} 17 && set mask 255.255.128.0 ||
iseq ${mask} 18 && set mask 255.255.192.0 ||
iseq ${mask} 19 && set mask 255.255.224.0 ||
iseq ${mask} 20 && set mask 255.255.240.0 ||
iseq ${mask} 21 && set mask 255.255.248.0 ||
iseq ${mask} 22 && set mask 255.255.252.0 ||
iseq ${mask} 23 && set mask 255.255.254.0 ||
iseq ${mask} 24 && set mask 255.255.255.0 ||
iseq ${mask} 25 && set mask 255.255.255.128 ||
iseq ${mask} 26 && set mask 255.255.255.192 ||
iseq ${mask} 27 && set mask 255.255.255.224 ||
iseq ${mask} 28 && set mask 255.255.255.240 ||
iseq ${mask} 29 && set mask 255.255.255.248 ||
set net${net}/netmask ${mask}
echo -n Enter gateway: ${}
read net${net}/gateway
echo -n Enter DNS server: ${}
read net${net}/dns
ifopen net${net}
goto boot
:link_vlan
echo -n Enter network card number [0 for net0, defaults to 0]: ${}
read net
isset ${net} || set net 0
echo -n Enter VLAN number: ${}
read vlan
vcreate --tag ${vlan} net${net}
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf net${net}-${vlan}
goto boot
:link_retry4
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf --configurator dhcp || goto link_menu
goto boot
:link_shell
shell
goto start
:link_chain
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf
chain https://${next-server}/ipxe/ipxe.lkrn || chain http://${next-server}/ipxe/ipxe.lkrn || chain chain ${next-server}/ipxe/ipxe.lkrn && exit ||
goto link_menu
:link_chain_woa7.github.io
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf
chain https://woa7.github.io/ipxe/ipxe.lkrn || chain http://woa7.github.io/ipxe/ipxe.lkrn && exit ||
goto link_menu
:link_chain_boot.salstar.sk
iflinkwait --timeout=60000 || echo Link wait failed!
ifconf
chain https://boot.salstar.sk/ipxe/ipxe.lkrn || chain http://boot.salstar.sk/ipxe/ipxe.lkrn && exit ||
goto link_menu
:link_reboot_warm
reboot --warm ||
:link_reboot
reboot ||
goto link_menu
:link_boot_ip
chain --autofree --replace ${base_ip}menu.ipxe ||
exit
:tftp
## FIXME ## set next-server 158.197.16.70
clear base
echo Trying to boot from tftp server at ${next-server} ...
goto boot_chain