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 diff --git a/packer_templates/http/ubuntu/user-data b/packer_templates/http/ubuntu/user-data index f1b517f1b..c8d22760d 100644 --- a/packer_templates/http/ubuntu/user-data +++ b/packer_templates/http/ubuntu/user-data @@ -15,7 +15,7 @@ autoinstall: late-commands: - | if [ -f /target/etc/netplan/00-installer-config.yaml ]; then - 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml' + sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml fi - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/vagrant # Enable hyper-v daemons only if using hyper-v virtualization