8

freebsd-update command prints updating entries after it downloaded. But it shows them with more. So I have to press some spaces to continue. Is there a way to avoid this behavior? I want to execute update fully automated manner.

Stefan Lasiewski
  • 22,949
  • 38
  • 129
  • 184
Eonil
  • 9,689
  • 15
  • 34
  • 53

1 Answers1

11

Before doing any of this make sure you are familiar with the freebsd-update process, possible ramifications, and requirements. Like any automated update there is a chance it will screw up.

Create the file /usr/local/etc/periodic/weekly/912.freebsd-update with the following:

#!/bin/sh -
#
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

case "$weekly_freebsd-update_enable" in
    [Yy][Ee][Ss])
        echo ""
        echo "Updating system via freebsd-update:"

        freebsd-update cron install;;

    *)  rc=0;;
esac

exit $rc

Don't forget chmod +x 912.freebsd-update
Enable it by adding weekly_freebsd-update_enable="YES" to /etc/periodic.conf
Your normal periodic report will contain the log results from the operation (e-mail to root by default).

The number 912 is arbitrary, it's just the number I use. You can pick anything in the 900 range and it should work fine.

Chris S
  • 77,337
  • 11
  • 120
  • 212
  • what about ports? what are the implications of such a script? "what could possibly go wrong?" :) will this perform point releases (e.g. 9.2 → 9.3) or major upgrades (e.g. 9.3 → 10.1)? – anarcat Nov 28 '14 at 14:28
  • Please reread the first line of this answer, I really meant it. The question was not about any of what you asked, just about automating that process. Ports aren't touched by freebsd-update, you'd need to automate portmaster, portupgrade, or possibly poudriere for that (and that *ain't easy* for some ports). What could go wrong: same as running any freebsd-update, mainly hardware issues in the middle of an upgrade; or a bad diff though that is unlikely from official sources. The script above does not jump versions; it would be much more complicated as you have to specify the new version. – Chris S Nov 30 '14 at 03:35