0

I have an ISO installation of ubuntu 18.04 which has a txt.cfg file in it.

the txt.cfg has 4 options in it, and a preseed file is selected based on the option chosen:

label option1
  menu option1
  kernel /install/vmlinuz
  append  file=/cdrom/option1.seed vga=788 initrd=/install/initrd.gz ...

label option2
  menu option2
  kernel /install/vmlinuz
  append  file=/cdrom/option2.seed vga=788 initrd=/install/initrd.gz ...

each of the seed files (in this example, option1.seed & option2.seed) sets up the partitions differently using d-i partman-auto/expert_recipe string.

Instead of the user having to choose the suitable partitioning option for him, I wrote a bash script which according to different parameters of the machine (CPU, RAM, etc..) can tell which option is suitable.

How can I run a bash script as part of the .cfg file or somewhere in the .seed file?

I saw usages of d-i preseed/late_command and d-i preseed/early_command but not sure how do use them.

  • `d-i preseed/early_command` can be used to run shell commands before the `preseed` process begins and you can deduce the other command. Is there some help for you here: https://askubuntu.com/a/1080528/531149? – ThunderBird May 31 '21 at 19:19
  • Hi, thanks for your answer. In the link you sent, `late_command` is being used and not `early_command` – Ofek Agmon Jun 01 '21 at 08:10
  • Alright, you're welcome. But have you tried it, nevertheless? Also, if you read my comment above well, I concluded the first sentence with `... and you can deduce the other command.`, just to note that the `preseed` process remains the `preseed` process and the `early_command` and/or `late_command` play their own described role(s) as well... I don't know if you understand me clearly..? – ThunderBird Jun 01 '21 at 14:33

1 Answers1

1

I think the txt.cfg is a config for SYSLINUX/ISOLINUX. I don't think it is capable of the dynamic options you are looking for.

I suggest using early_command to copy an appropriate recipe to a specific path used by the preseed expert_recipe_file option. The same preseed file is used for all installs, but the recipe file can be chosen based on whatever logic is desired.

For example, I will use options similar to these in my preseed file to choose either a UEFI or BIOS based recipe.

d-i preseed/early_command string \
  if [ -d /sys/firmware/efi/ -o -d /proc/efi ]; then \
    cp /cdrom/recipe_efi  /run/my_recipe ; \
  else \
    cp /cdrom/recipe_bios /run/my_recipe ; \
  fi ;

d-i partman-auto/expert_recipe_file string /run/my_recipe
Andrew Lowther
  • 5,811
  • 1
  • 15
  • 23