#!ipxe

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

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 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_nfs 10.10.50.10:/srv/provision/nfs/ubuntu-24.04/group-d/l1-v1.13

menu Provision Server

item --gap -- ---------------- Device Groups ----------------
item group_a Install device Group A
item group_b Install device Group B
item group_c Install device Group C
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
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
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
echo Selected: Group C
echo Ubuntu 24.04 autoinstall via NFS + HTTP NoCloud.
prompt Press any key to continue with Group C 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_d
#echo Selected: Group D
#echo This will boot Clonezilla Live L1 v1.13 over PXE.
#prompt Press any key to continue with Group D Clonezilla boot...
#kernel ${clonezilla_d_kernel} initrd=initrd.img boot=live union=overlay config components noswap edd=on nomodeset net.ifnames=0 biosdevname=0 ip=:::::eth0:dhcp ethdevice=eth0 locales=ru_RU.UTF-8 keyboard-layouts=us ocs_live_batch=no fetch=${clonezilla_d_squashfs} ---
#initrd --name initrd.img ${clonezilla_d_initrd}
#boot

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

item --gap -- ---------------- Available images ----------------
item d_tp       Restore TP-v1.12 to /dev/sda
item d_avc      Restore AVC-v1.12 to /dev/sda
item d_dwlatm   Restore DW-LATM-v1.12 to /dev/sda
item d_dw       Restore DW-v1.12 to /dev/sda
item d_latm     Restore LATM-v1.12 to /dev/sda
item d_shell    Boot Clonezilla shell only
item reboot     Reboot

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

:d_tp
set cz_image TP-v1.12
goto clonezilla_restore

:d_avc
set cz_image AVC-v1.12
goto clonezilla_restore

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

:d_dw
set cz_image DW-v1.12
goto clonezilla_restore

:d_latm
set cz_image LATM-v1.12
goto clonezilla_restore

:d_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/sda
prompt WARNING: /dev/sda 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_repository=nfs_server:10.10.50.10:/srv/provision/nfs/ubuntu-24.04/group-d/l1-v1.13/home/partimag ocs_live_run=\"ocs-sr\" ocs_live_extra_param=\"-g auto -batch -r -j2 -cm -o0 -o1 -p true restoredisk ${cz_image} sda\" ocs_live_batch=\"yes\" vga=788 nosplash ---
initrd --name initrd.img ${clonezilla_d_initrd}
boot

:shell
shell

:reboot
reboot
