#!ipxe

set server_ip 10.10.50.10
set base_url http://${server_ip}

# ------------------------------------------------------------------
# Ubuntu 24.04 Group A/B/C
# ------------------------------------------------------------------
set custom_kernel ${base_url}/images/ubuntu-24.04/group-a/custom-os/vmlinuz
set custom_initrd ${base_url}/images/ubuntu-24.04/group-a/custom-os/initrd
set custom_nfs 10.10.50.10:/srv/provision/nfs/ubuntu-24.04/group-a/custom-os
set anprc_c_kernel ${base_url}/images/ubuntu-24.04/group-c/anprc-v2/vmlinuz
set anprc_c_initrd ${base_url}/images/ubuntu-24.04/group-c/anprc-v2/initrd
set anprc_c_nfs 10.10.50.10:/srv/provision/nfs/ubuntu-24.04/group-c/anprc-v2
# ------------------------------------------------------------------
# Clonezilla Group D - L1 v1.13
# Kernel/initrd/squashfs are loaded by HTTP.
# /home/partimag is mounted manually by ocs_prerun.
# ------------------------------------------------------------------
set clonezilla_d_base ${base_url}/images/clonezilla/group-d/l1-v1.13
set clonezilla_d_kernel ${clonezilla_d_base}/vmlinuz
set clonezilla_d_initrd ${clonezilla_d_base}/initrd.img
set clonezilla_d_squashfs ${clonezilla_d_base}/filesystem.squashfs

set clonezilla_d_partimag_server 10.10.50.10
set clonezilla_d_partimag_path /srv/provision/nfs/ubuntu-24.04/group-d/l1-v1.13/home/partimag
set clonezilla_d_disk sda

# ------------------------------------------------------------------
# Main menu
# ------------------------------------------------------------------
menu Provision Server

item --gap -- ---------------- Device Groups ----------------
item group_a Install device Group A - Ubuntu 24.04 dw
item group_b Install device Group B - Ubuntu 24.04 autoinstall
item group_c Install device Group C - Ubuntu 24.04 anprc-v2
item group_d Install device Group D - Clonezilla L1 v1.13

item --gap -- ---------------- Tools ----------------
item shell iPXE shell
item reboot Reboot

choose --default group_a --timeout 10000 target && goto ${target}


# ------------------------------------------------------------------
# Group A
# ------------------------------------------------------------------
:group_a
echo Selected: Group A
echo Ubuntu 24.04 autoinstall via NFS + HTTP NoCloud.
prompt Press any key to continue with Group A installation...

kernel ${custom_kernel} initrd=initrd ip=dhcp boot=casper netboot=nfs nfsroot=${custom_nfs} autoinstall ds=nocloud-net\;s=${base_url}/autoinstall/group-a/ ---
initrd --name initrd ${custom_initrd}
boot


# ------------------------------------------------------------------
# Group B
# Пока использует тот же custom-os и autoinstall, что Group A.
# ------------------------------------------------------------------
:group_b
echo Selected: Group B
echo Ubuntu 24.04 autoinstall via NFS + HTTP NoCloud.
prompt Press any key to continue with Group B installation...

kernel ${custom_kernel} initrd=initrd ip=dhcp boot=casper netboot=nfs nfsroot=${custom_nfs} autoinstall ds=nocloud-net\;s=${base_url}/autoinstall/group-a/ ---
initrd --name initrd ${custom_initrd}
boot


# ------------------------------------------------------------------
# Group C
# Пока использует тот же custom-os и autoinstall, что Group A.
# ------------------------------------------------------------------
:group_c
echo Selected: Group C
echo Ubuntu 24.04 ANPRC v2 autoinstall via NFS + HTTP NoCloud.
echo Kernel: ${anprc_c_kernel}
echo Initrd: ${anprc_c_initrd}
echo NFS: ${anprc_c_nfs}
echo NoCloud: ${base_url}/autoinstall/group-c/
imgfree
kernel ${anprc_c_kernel} initrd=initrd ip=dhcp boot=casper netboot=nfs nfsroot=${anprc_c_nfs} autoinstall ds=nocloud-net;s=${base_url}/autoinstall/group-c/ ---
initrd --name initrd ${anprc_c_initrd}
imgstat
boot

# ------------------------------------------------------------------
# Group D - Clonezilla image selection menu
# ------------------------------------------------------------------
:group_d
menu Group D - Clonezilla L1 v1.13 image selection

item --gap -- ---------------- Available images ----------------
item d_tp       Restore TP-v1.13 to /dev/sda
item d_avc      Restore AVC-v1.13 to /dev/sda
item d_dwlatm   Restore DW-LATM-v1.13 to /dev/sda
item d_dw       Restore DW-v1.13 to /dev/sda
item d_latm     Restore LATM-v1.13 to /dev/sda

item --gap -- ---------------- Tools ----------------
item d_clonezilla_shell Boot Clonezilla shell only
item main               Back to main menu
item reboot             Reboot

choose --default d_tp --timeout 15000 cz_target && goto ${cz_target}


:d_tp
set cz_image TP-v1.13
goto clonezilla_restore


:d_avc
set cz_image AVC-v1.13
goto clonezilla_restore


:d_dwlatm
set cz_image DW-LATM-v1.13
goto clonezilla_restore


:d_dw
set cz_image DW-v1.13
goto clonezilla_restore


:d_latm
set cz_image LATM-v1.13
goto clonezilla_restore


:d_clonezilla_shell
echo Booting Clonezilla shell mode...

kernel ${clonezilla_d_kernel} initrd=initrd.img boot=live union=overlay username=user config components noeject noswap edd=on nomodeset locales=en_US.UTF-8 keyboard-layouts=NONE ip=dhcp net.ifnames=0 biosdevname=0 fetch=${clonezilla_d_squashfs} ocs_live_batch=no ---
initrd --name initrd.img ${clonezilla_d_initrd}
boot


:clonezilla_restore
echo Selected image: ${cz_image}
echo Target disk: /dev/${clonezilla_d_disk}
echo NFS repository: ${clonezilla_d_partimag_server}:${clonezilla_d_partimag_path}
prompt WARNING: /dev/${clonezilla_d_disk} will be overwritten. Press any key to continue...

kernel ${clonezilla_d_kernel} initrd=initrd.img boot=live union=overlay username=user config components noeject noswap edd=on nomodeset locales=en_US.UTF-8 keyboard-layouts=NONE ip=dhcp net.ifnames=0 biosdevname=0 fetch=${clonezilla_d_squashfs} ocs_prerun1="mkdir -p /home/partimag" ocs_prerun2="mount -t nfs -o ro,nolock ${clonezilla_d_partimag_server}:${clonezilla_d_partimag_path} /home/partimag" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k1 -scr -p reboot restoredisk ${cz_image} ${clonezilla_d_disk}" ocs_live_batch=yes vga=788 nosplash ---
initrd --name initrd.img ${clonezilla_d_initrd}
boot


# ------------------------------------------------------------------
# Tools
# ------------------------------------------------------------------
:main
chain ${base_url}/ipxe/boot.ipxe


:shell
shell


:reboot
reboot
