Skip to content

Commit

Permalink
Fix a bug in freebsd-14.x due to changes in bsdinstall
Browse files Browse the repository at this point in the history
Since FreeBSD 14.0, bsdinstall creates ZFS dataset for `home` rather
than `/usr/home`, see
freebsd/freebsd-src@3bb9230.
This way, the previous workaround was broken, preventing the normal
provisioning of the default Vagrant public keys.

Signed-off-by: Anton Alekseev <[email protected]>
  • Loading branch information
antonalekseev committed Jul 18, 2024
1 parent 6fe9fa2 commit d6ef35c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packer_templates/http/freebsd/installerconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d6ef35c

Please sign in to comment.