Solved bsdinstall installerconfig copy files to chrooted new system

Hello,

I'm using a custom ISO with a bsdinstall installerconfig script.

What I know is that installerconfig is splitted by bsdinstall and everything behind the shebang (included itself) is executed after installation in the chrooted new system freshly installed. And that works pretty well ;)

But, I can't achieve a file copy from my custom ISO to the new system ! Hence I'm limited to the old school cat in the second part of my installerconfig...
cat > /my/new/system/file.sh << EOL
And I have to escape my $ to make them print on the final file...

Anyone with a clever idea ?

I appreciate your time on reading,
B
 
OK, I re (re) RTFM bsdinstall(8)...

For the record, the first part of installerconfig called PREAMBLE is:
[...] interpreted as a sh(1) script run at the very beginning of the install [...]
.
Which led me to just write cp /my/customiso/file.sh /mnt/etc/file.sh in the preamble, but I was wrong, /mnt is nothing and readonly on this step...

Then I read bsdinstall script content.

No way to get the new system to RW without "rewriting" a part of bsdinstall script (between the execution of /tmp/bsdinstall-installscript-aa and /tmp/bsdinstall-installscript-ab).

So I ended up altering /usr/libexec/bsdinstall/script on my custom ISO with cp /my/customiso/file.sh $BSDINSTALL_CHROOT/etc/file.sh just before it copies itself bsdinstall-installscript-ab to the new system...
 
Guys, is there in-depth bsdinstall documentation/reference covering its non-interactive use? I couldn't google up any. Or is trying to make sense of bsdinstall's and /usr/share/bsdconfig/* source code the only way? Which doesn't have much documentation either.
 
Or is trying to make sense of bsdinstall's and /usr/share/bsdconfig/* source code the only way?
The bsdinstall(8) manual, SCRIPTING section should cover what you want to know.

Basically
  • if a /etc/installerconfig file is present on a installer media, it will be executed instead of the menu guided installation.
  • installerconfig must contain a "preamble", and optional a "setup script" section
See example installerconfig scripts for UFS and ZFS, and ENVIRONMENT VARIABLES to customize the configuration, note BUILDING AUTOMATIC INSTALL MEDIA on how to add installerconfig on a iso image.

To get familiar with non-interactive installations, create a virtual machine and experiment. I prefer .img installation media images (directly attached to the VM on bhyve(8), or converted to virtual disks on VirtualBox (convertfromraw)), so that the installerconfig file can be easily edited.

These images can be mounted read/write in single-user mode or via fstab, unlike ISO images, which are read-only, and must be recreated every time the installerconfig file is modified.
 
Thanks, I should've made it clear that I've read bsdinstall's manual page on scripting. But, for instance, there's this example in the manpage:
Code:
export nonInteractive="YES"
which led me to want to see all other options and their intended use, in a reference format.
 
For example, how is it possible to set the DISTRIBUTIONS list dynamically, so I can use a single installer ISO to bootstrap several kinds of machines? Just a plain shell script and a callback function that would be invoked to provide the needed variables for bsdinstall dynamically would've been great.
 
Back
Top