freebsd / crochet

Build FreeBSD images for RaspberryPi, BeagleBone, PandaBoard, and others.
BSD 2-Clause "Simplified" License
609 stars 187 forks source link

Resolv option - can we pls add /etc/hosts #210

Closed sysxdotbiz closed 6 years ago

sysxdotbiz commented 6 years ago

Just in case there are entries in hosts that are not resolved by the DNS servers specified in resolv.conf - a situation that occurred for me recently. e.g.

copy_resolv_conf ( ) { echo "Copying host's resolv.conf and hosts" cp /etc/resolv.conf ${BOARD_FREEBSD_MOUNTPOINT}/etc/resolv.conf cp /etc/hosts ${BOARD_FREEBSD_MOUNTPOINT}/etc/hosts }

Or something similar. Thanks.

kientzle commented 6 years ago

You can already do this.

If you just want these files in the image, then just copy them into the overlay in your config file:

cp /etc/resolv.conf <overlay dir>/etc/resolv.conf
cp /etc/hosts <overlay dir>/etc/hosts

The config file is ultimately just a set of shell commands that run before anything else. In this case, the standard overlay handling will then take care of copying the files into the image.

If you need them at some other point in the process for some reason, you can define a custom function and have it run at any point:

strategy add <priority> copy_resolv_conf

If you think this will be useful to other people, consider making it an Option and contributing it.