Scripting FreeBSD pkg Installs


The Blog of Tom Webster

  2016-05-18 14:34:41 PDT

I needed to bootstrap pkg and install some packages in FreeBSD via a script, but the pkg was getting hung up on the interactive element. Thanks to this forum post (which references this blog post, I now can.

Use env ASSUME_ALWAYS_YES=YES pkg bootstrap to get pkg up and running, you can use that same env line to install packages without any prompts, like this:

env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install git zsh curl

pkg won't prompt you and will install the packages. Great for scripting or ezjail flavours.