DigitalOcean, FreeBSD 12.4 and ldconfig

Once upon a time, DigitalOcean offered FreeBSD droplets. I had one for many years, and this morning I decided to upgrade from FreeBSD 12.3 to 12.4. The upgrade went well until the last reboot after running pkg-static upgrade -f to reinstall all installed packages.

After the reboot, the droplet didn’t get IP addresses configured while the /etc/rc.conf file had ifconfig_vtnet0="DHCP". I was able to set the IP and default route manually and remotely login to the droplet. At the end of /etc/rc.conf, I noticed DigitalOcean added some generated content that reconfigured the network, but information was missing. I attempted to re-configure droplet to use static IP address, and to test the change I rebooted the droplet a few times, but it wasn’t sucesfull: I would always end up with misconfigured networking. While doing another reboot I noticed errors quckly scroll:

DigitalOcean: reading meta-data
...
ld-elf.so.1: Shared object "libonig.so.5" not found, required bu "jq"

The library jq was linked to was missing during the boot, but it wasn’t missing when I tried running jq in the shell. ldd showed the proper path to the libraries used.

In /etc/rc.conf, two Digital Ocean provided startup scripts were enabled: digitalocean and digitaloceanpre. I attempted to disable them (set digitalocean_enabled="NO") and rebooted, but it didn’t help: startup scripts still ran. I then inspected the startup files and found that /usr/local/etc/rc.d/digitalocean was responsible for the jq issue. It configured the network using a JSON file from the CloudDrive, which was mounted by /usr/local/etc/rc.d/digitaloceanpre.

The fix was simple: add ldconfig to the REQUIRE services for /usr/local/etc/rc.d/digitalocean and reboot. This allowed ldconfig to set up the library path before starting digitalocean, which used jq.