Solved How can I run 'freebsd-update' and 'pkg' non-interactively?

Problem:
Postinstaller script needs to update system after install from ISO media.
freebsd-update and pkg ask the user for interactive confirmations.

Question:
As there is no "-y" option or similar, what is the recommended way to let these programs just run without stopping for manual confirmation, assuming "yes" as default answer?
 
As there is no "-y" option or similar
pkg-install(8) disagrees:
Code:
     -y, --yes  Assume yes when asked for confirmation before package
                installation.
This one's useful too:
Code:
     ASSUME_ALWAYS_YES

Code:
 # env ASSUME_ALWAYS_YES=YES pkg install -y ipmitool
Updating dicelan repository catalogue...
dicelan repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        ipmitool: 1.8.18_3

Number of packages to be installed: 1

The process will require 1 MiB more space.
390 KiB to be downloaded.
[1/1] Fetching ipmitool-1.8.18_3.txz: 100%  390 KiB 399.5kB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Installing ipmitool-1.8.18_3...
[1/1] Extracting ipmitool-1.8.18_3: 100%

If you're looking for a simple way to automatically install packages for images (VM disk images for example), then sysutils/firstboot-pkgs is quite useful. As for freebsd-update(8), there's sysutils/firstboot-freebsd-update. sysutils/firstboot-growfs is quite useful too.
 
Great thank you :)
In particular the hint to ASSUME_ALWAYS_YES might be helpful to avoid annoying occasional yesno stoppages :)

Somehow I only looked at the options section in the pkg man page and missed to see the "See also", where pkg-install was mentioned ?‍♂️
 
Finally, after all the dryrunning and issues with a bad tester PC, I have set up another tester PC.

Now I am stuck again.
When the script runs freebsd-update, it stops, showing me:
"The following files will be updated as part of updating to <more_recent_patchlevel>: <loooong_list>".

To continue, I have to leave the pager pressing "q".

Is there a clean way to suppress this stoppage and just continue?
 
You should really learn to read the man pages, freebsd-update(8):
Code:
     PAGER  The pager program used to present various reports during the
            execution.  (Default: "/usr/bin/less".)

            PAGER can be set to "cat" when a non-interactive pager is desired.
 
Umm... I read the man page several times, but didn't find a PAGER setting.
Even man 8 freebsd-update|grep PAGER doesn't show me anything.
I must have the Muggel's Edition of the man pages.

Where did you get the Wizard's version of the man page? :)
Thank you very much again, SirDice!
 
That's really cool :)
Many thanks to you and to 0mp who added that important info detail to the man page ?
 
This is a solution I came up with while running the process in zsh via rundeck: export PAGER=cat ; sudo -E pkg upgrade -y
 
Just wanted to ask why that long list of files to be updated is even displayed.
Would anyone actually scrutinize that interactively?

Perhaps the list could be dropped into a file for review if the user desires?
 
Back
Top