How can I run the command "pkg" from the host for the first time

Once the jail has been created, how can I programmatically run the command pkg inside it from the host and automatically answer y when prompted to bootstrap pkg for the first time?
 
env ASSUME_ALWAYS_YES=true pkg install -y ...

Code:
     -y, --yes  Assume yes when asked for confirmation before package
                installation.
pkg-install(8)
Code:
     ASSUME_ALWAYS_YES: boolean
                  When this option is enabled pkg(1) will automatically assume
                  "yes" to all questions which require user confirmation
                  before doing anything, as if the -y flag was specified.
                  Default: NO.
pkg.conf(5)
 
From memory you can probably use jexec with the name of the jail and the command you want to run

If you are using Freebsd 15 with the new distribution sets
instead of the legacy set up you dont have to bootstrap pkg
 
Code:
     -j ⟨jail name or id⟩, --jail ⟨jail name or id⟩
             pkg will execute in the given ⟨jail name or id⟩, where name
             matches “jls name” and id matches “jls jid”.  See jail(8) and
             jls(8).

     -c ⟨chroot path⟩, --chroot ⟨chroot path⟩
             pkg will chroot in the ⟨chroot path⟩ environment.
pkg(8)
 
Back
Top