137 lines
4.1 KiB
Plaintext
137 lines
4.1 KiB
Plaintext
#!ipxe
|
|
echo
|
|
echo Warewulf v4 (iPXE)
|
|
echo
|
|
set next start
|
|
goto metadata
|
|
|
|
:start
|
|
{{- if not .ImageName }}
|
|
echo !!
|
|
echo !! No image defined for {{.Fqdn}}.
|
|
echo !! Rebooting in 30s...
|
|
echo !!
|
|
sleep 30
|
|
reboot
|
|
{{- end }}
|
|
|
|
set baseuri http://{{.Authority}}/provision/{{.Hwaddr}}
|
|
set uri ${baseuri}?assetkey=${asset}&uuid=${uuid}
|
|
|
|
echo Downloading kernel image...
|
|
kernel --name kernel ${uri}&stage=kernel || goto reboot
|
|
|
|
{{- if .Tags.IPXEMenuEntry }}
|
|
set method {{ .Tags.IPXEMenuEntry }}
|
|
{{- else }}
|
|
# https://github.com/warewulf/warewulf/issues/222
|
|
iseq ${platform} efi && set method imgextract || set method initrd
|
|
{{- end }}
|
|
|
|
:menu
|
|
menu Warewulf v4 image provisioning method
|
|
item imgextract Single-stage with imgextract
|
|
item initrd Single-stage with initrd
|
|
item initrd_nocompress Single stage with initrd (no compression)
|
|
item dracut Two stage with dracut
|
|
item shell iPXE shell
|
|
choose --default ${method} --timeout 2000 method && goto ${method} || goto menu
|
|
|
|
:imgextract
|
|
set next imgextract_continue
|
|
goto metadata
|
|
:imgextract_continue
|
|
echo
|
|
echo Downloading compressed image with imgextract...
|
|
imgextract --name image ${uri}&stage=image&compress=gz || goto error_use_initrd
|
|
echo Downloading compressed system overlay image with imgextract...
|
|
imgextract --name system ${uri}&stage=system&compress=gz || goto error_reboot
|
|
{{- if not (eq .Https true) }}
|
|
echo Downloading compressed runtime overlay image with imgextract...
|
|
imgextract --name runtime ${uri}&stage=runtime&compress=gz && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
|
|
{{- end }}
|
|
goto boot_single_stage
|
|
|
|
:error_use_initrd
|
|
echo Encountered an error. Now using initrd.
|
|
goto initrd_continue
|
|
|
|
:initrd
|
|
set next initrd_continue
|
|
goto metadata
|
|
:initrd_continue
|
|
echo
|
|
echo Downloading compressed image with initrd...
|
|
initrd --name image ${uri}&stage=image&compress=gz || goto error_reboot
|
|
echo Downloading compressed system overlay with initrd...
|
|
initrd --name system ${uri}&stage=system&compress=gz || goto error_reboot
|
|
{{- if not (eq .Https true) }}
|
|
echo Downloading compressed runtime overlay with initrd...
|
|
initrd --name runtime ${uri}&stage=runtime&compress=gz && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
|
|
{{- end }}
|
|
goto boot_single_stage
|
|
|
|
:initrd_nocompress
|
|
set next initrd_nocompress_continue
|
|
goto metadata
|
|
:initrd_nocompress_continue
|
|
echo
|
|
echo Downloading uncompressed image with initrd...
|
|
initrd --name image ${uri}&stage=image || goto error_reboot
|
|
echo Downloading uncompressed system overlay with initrd...
|
|
initrd --name system ${uri}&stage=system || goto error_reboot
|
|
{{- if not (eq .Https true) }}
|
|
echo Downloading uncompressed runtime overlay with initrd...
|
|
initrd --name runtime ${uri}&stage=runtime && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
|
|
{{- end }}
|
|
goto boot_single_stage
|
|
|
|
:dracut
|
|
set next dracut_continue
|
|
goto metadata
|
|
:dracut_continue
|
|
echo
|
|
echo Downloading dracut initramfs...
|
|
initrd --name initramfs ${uri}&stage=initramfs || goto error_reboot
|
|
set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} ip={{$netdev.Device}}:dhcp {{end}}{{end}}
|
|
set dracut_wwinit root=wwinit:{{default "tmpfs" .Root}} wwinit.uri=${baseuri} init=/warewulf/run-init
|
|
goto boot_two_stage_dracut
|
|
|
|
:boot_single_stage
|
|
echo Booting (single stage)...
|
|
boot kernel initrd=image initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}} || goto error_reboot
|
|
|
|
:boot_two_stage_dracut
|
|
echo Booting dracut (first stage)...
|
|
boot kernel initrd=initramfs ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}} || error_reboot
|
|
|
|
:error_reboot
|
|
echo !!
|
|
echo !! Encountered an error.
|
|
echo !! rebooting in 15s...
|
|
echo !!
|
|
sleep 15
|
|
reboot
|
|
|
|
:shell
|
|
shell
|
|
goto menu
|
|
|
|
:metadata
|
|
echo Warewulf Server:
|
|
echo * Ipaddr: {{.Ipaddr}}
|
|
echo * Port: {{.Port}}
|
|
echo * Authority: {{.Authority}}
|
|
echo
|
|
echo This node:
|
|
echo * Fqdn: {{.Fqdn}}
|
|
echo * Hwaddr: {{.Hwaddr}}
|
|
echo * ImageName: {{.ImageName}}
|
|
{{- if .KernelVersion }}
|
|
echo * KernelVersion: {{.KernelVersion}}
|
|
{{- else }}
|
|
echo * KernelVersion: (image default)
|
|
{{- end }}
|
|
echo * KernelArgs: {{.KernelArgs}}
|
|
goto ${next}
|