From 4496079764dcc3719a49753f766a0b2c02e9bc94 Mon Sep 17 00:00:00 2001 From: Anton Alekseev Date: Tue, 23 Jul 2024 01:19:10 +0700 Subject: [PATCH] Fix a bug in freebsd-14.x due to changes in bsdinstall (#1573) Since FreeBSD 14.0, bsdinstall creates ZFS dataset for `home` rather than `/usr/home`, see https://github.com/freebsd/freebsd-src/commit/3bb92304b4fe79babd19ba0d9c74d29af9117a22. This way, the previous workaround was broken, preventing the normal provisioning of the default Vagrant public keys. Signed-off-by: Anton Alekseev Co-authored-by: Corey Hemminger --- packer_templates/http/freebsd/installerconfig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packer_templates/http/freebsd/installerconfig b/packer_templates/http/freebsd/installerconfig index 02045660c..726c8130d 100644 --- a/packer_templates/http/freebsd/installerconfig +++ b/packer_templates/http/freebsd/installerconfig @@ -44,12 +44,22 @@ EOT # zfs doesn't use an fstab, but some rc scripts expect one touch /etc/fstab +# Since FreeBSD 14.0 bsdinstall again creates dataset for /home rather then /usr/home +# Thus on versions prior to 14.0 we have to create /home -> /usr/home symlink, +# otherwise just use /home as the base for vagrant's home +version=$(freebsd-version -u) +if [ "${version%%.*}" -lt "14" ]; then + home_base="/usr/home" + ln -s $home_base /home +else + home_base="/home" +fi + # Set up user accounts -echo "vagrant" | pw -V /etc useradd vagrant -h 0 -s /bin/sh -G wheel -d /usr/home/vagrant -c "Vagrant User" +echo "vagrant" | pw -V /etc useradd vagrant -h 0 -s /bin/sh -G wheel -d ${home_base}/vagrant -c "Vagrant User" echo "vagrant" | pw -V /etc usermod root -mkdir -p /usr/home/vagrant -chown 1001:1001 /usr/home/vagrant -ln -s /usr/home /home +mkdir -p ${home_base}/vagrant +chown 1001:1001 ${home_base}/vagrant reboot