freebsd-update.sh (352610) | freebsd-update.sh (352758) |
---|---|
1#!/bin/sh 2 3#- 4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5# 6# Copyright 2004-2007 Colin Percival 7# All rights reserved 8# --- 13 unchanged lines hidden (view full) --- 22# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28# POSSIBILITY OF SUCH DAMAGE. 29 | 1#!/bin/sh 2 3#- 4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5# 6# Copyright 2004-2007 Colin Percival 7# All rights reserved 8# --- 13 unchanged lines hidden (view full) --- 22# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28# POSSIBILITY OF SUCH DAMAGE. 29 |
30# $FreeBSD: stable/11/usr.sbin/freebsd-update/freebsd-update.sh 352610 2019-09-22 20:03:25Z grembo $ | 30# $FreeBSD: stable/11/usr.sbin/freebsd-update/freebsd-update.sh 352758 2019-09-26 16:33:20Z grembo $ |
31 32#### Usage function -- called from command-line handling code. 33 34# Usage instructions. Options not listed: 35# --debug -- don't filter output from utilities 36# --no-stats -- don't show progress statistics while fetching files 37usage () { 38 cat <<EOF --- 18 unchanged lines hidden (view full) --- 57 -- Run without a tty, for use by automated tools 58 --currently-running release 59 -- Update as if currently running this release 60Commands: 61 fetch -- Fetch updates from server 62 cron -- Sleep rand(3600) seconds, fetch updates, and send an 63 email if updates were found 64 upgrade -- Fetch upgrades to FreeBSD version specified via -r option | 31 32#### Usage function -- called from command-line handling code. 33 34# Usage instructions. Options not listed: 35# --debug -- don't filter output from utilities 36# --no-stats -- don't show progress statistics while fetching files 37usage () { 38 cat <<EOF --- 18 unchanged lines hidden (view full) --- 57 -- Run without a tty, for use by automated tools 58 --currently-running release 59 -- Update as if currently running this release 60Commands: 61 fetch -- Fetch updates from server 62 cron -- Sleep rand(3600) seconds, fetch updates, and send an 63 email if updates were found 64 upgrade -- Fetch upgrades to FreeBSD version specified via -r option |
65 updatesready -- Check if there are fetched updates ready to install |
|
65 install -- Install downloaded updates or upgrades 66 rollback -- Uninstall most recently installed updates | 66 install -- Install downloaded updates or upgrades 67 rollback -- Uninstall most recently installed updates |
67 IDS -- Compare the system against an index of "known good" files. | 68 IDS -- Compare the system against an index of "known good" files 69 showconfig -- Show configuration |
68EOF 69 exit 0 70} 71 72#### Configuration processing functions 73 74#- 75# Configuration options are set in the following order of priority: --- 422 unchanged lines hidden (view full) --- 498 --debug) 499 config_VerboseLevel debug || usage 500 ;; 501 --no-stats) 502 config_VerboseLevel nostats || usage 503 ;; 504 505 # Commands | 70EOF 71 exit 0 72} 73 74#### Configuration processing functions 75 76#- 77# Configuration options are set in the following order of priority: --- 422 unchanged lines hidden (view full) --- 500 --debug) 501 config_VerboseLevel debug || usage 502 ;; 503 --no-stats) 504 config_VerboseLevel nostats || usage 505 ;; 506 507 # Commands |
506 cron | fetch | upgrade | install | rollback | IDS) | 508 cron | fetch | upgrade | updatesready | install | rollback |\ 509 IDS | showconfig) |
507 COMMANDS="${COMMANDS} $1" 508 ;; 509 510 # Anything else is an error 511 *) 512 usage 513 ;; 514 esac --- 307 unchanged lines hidden (view full) --- 822 # Construct a unique name from ${BASEDIR} 823 BDHASH=`echo ${BASEDIR} | sha256 -q` 824 825 # Check that we have updates ready to install 826 if ! [ -L ${BDHASH}-install ]; then 827 echo "No updates are available to install." 828 if [ $ISFETCHED -eq 0 ]; then 829 echo "Run '$0 fetch' first." | 510 COMMANDS="${COMMANDS} $1" 511 ;; 512 513 # Anything else is an error 514 *) 515 usage 516 ;; 517 esac --- 307 unchanged lines hidden (view full) --- 825 # Construct a unique name from ${BASEDIR} 826 BDHASH=`echo ${BASEDIR} | sha256 -q` 827 828 # Check that we have updates ready to install 829 if ! [ -L ${BDHASH}-install ]; then 830 echo "No updates are available to install." 831 if [ $ISFETCHED -eq 0 ]; then 832 echo "Run '$0 fetch' first." |
830 exit 1 | 833 exit 2 |
831 fi 832 exit 0 833 fi 834 if ! [ -f ${BDHASH}-install/INDEX-OLD ] || 835 ! [ -f ${BDHASH}-install/INDEX-NEW ]; then 836 echo "Update manifest is corrupt -- this should never happen." 837 echo "Re-run '$0 fetch'." 838 exit 1 --- 2489 unchanged lines hidden (view full) --- 3328} 3329 3330# Fetch files for upgrading to a new release. 3331cmd_upgrade () { 3332 upgrade_check_params 3333 upgrade_run || exit 1 3334} 3335 | 834 fi 835 exit 0 836 fi 837 if ! [ -f ${BDHASH}-install/INDEX-OLD ] || 838 ! [ -f ${BDHASH}-install/INDEX-NEW ]; then 839 echo "Update manifest is corrupt -- this should never happen." 840 echo "Re-run '$0 fetch'." 841 exit 1 --- 2489 unchanged lines hidden (view full) --- 3331} 3332 3333# Fetch files for upgrading to a new release. 3334cmd_upgrade () { 3335 upgrade_check_params 3336 upgrade_run || exit 1 3337} 3338 |
3339# Check if there are fetched updates ready to install 3340cmd_updatesready () { 3341 # Construct a unique name from ${BASEDIR} 3342 BDHASH=`echo ${BASEDIR} | sha256 -q` 3343 3344 # Check that we have updates ready to install 3345 if ! [ -L ${BDHASH}-install ]; then 3346 echo "No updates are available to install." 3347 exit 2 3348 fi 3349 3350 echo "There are updates available to install." 3351 echo "Run '$0 install' to proceed." 3352} 3353 |
|
3336# Install downloaded updates. 3337cmd_install () { 3338 install_check_params 3339 install_run || exit 1 3340} 3341 3342# Rollback most recently installed updates. 3343cmd_rollback () { 3344 rollback_check_params 3345 rollback_run || exit 1 3346} 3347 3348# Compare system against a "known good" index. 3349cmd_IDS () { 3350 IDS_check_params 3351 IDS_run || exit 1 3352} 3353 | 3354# Install downloaded updates. 3355cmd_install () { 3356 install_check_params 3357 install_run || exit 1 3358} 3359 3360# Rollback most recently installed updates. 3361cmd_rollback () { 3362 rollback_check_params 3363 rollback_run || exit 1 3364} 3365 3366# Compare system against a "known good" index. 3367cmd_IDS () { 3368 IDS_check_params 3369 IDS_run || exit 1 3370} 3371 |
3372# Output configuration. 3373cmd_showconfig () { 3374 for X in ${CONFIGOPTIONS}; do 3375 echo $X=$(eval echo \$${X}) 3376 done 3377} 3378 |
|
3354#### Entry point 3355 3356# Make sure we find utilities from the base system 3357export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH} 3358 3359# Set a pager if the user doesn't 3360if [ -z "$PAGER" ]; then 3361 PAGER=/usr/bin/more 3362fi 3363 3364# Set LC_ALL in order to avoid problems with character ranges like [A-Z]. 3365export LC_ALL=C 3366 3367get_params $@ 3368for COMMAND in ${COMMANDS}; do 3369 cmd_${COMMAND} 3370done | 3379#### Entry point 3380 3381# Make sure we find utilities from the base system 3382export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH} 3383 3384# Set a pager if the user doesn't 3385if [ -z "$PAGER" ]; then 3386 PAGER=/usr/bin/more 3387fi 3388 3389# Set LC_ALL in order to avoid problems with character ranges like [A-Z]. 3390export LC_ALL=C 3391 3392get_params $@ 3393for COMMAND in ${COMMANDS}; do 3394 cmd_${COMMAND} 3395done |