Changeset View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | -s server -- Server from which to fetch updates | ||||
(default: update.FreeBSD.org) | (default: update.FreeBSD.org) | ||||
-t address -- Mail output of cron command, if any, to address | -t address -- Mail output of cron command, if any, to address | ||||
(default: root) | (default: root) | ||||
--not-running-from-cron | --not-running-from-cron | ||||
-- Run without a tty, for use by automated tools | -- Run without a tty, for use by automated tools | ||||
--currently-running release | --currently-running release | ||||
-- Update as if currently running this release | -- Update as if currently running this release | ||||
Commands: | Commands: | ||||
fetch -- Fetch updates from server | fetch -- Fetch updates from server | ||||
cron -- Sleep rand(3600) seconds, fetch updates, and send an | cron -- Sleep rand(3600) seconds, fetch updates, and send an | ||||
email if updates were found | email if updates were found | ||||
upgrade -- Fetch upgrades to FreeBSD version specified via -r option | upgrade -- Fetch upgrades to FreeBSD version specified via -r option | ||||
updatesready -- Check if there are fetched updates ready to install | |||||
yuripv: nit: other commands don't have trailing dot (same for config) except for IDS, doesn't look… | |||||
Done Inline ActionsIDS had, which was the one I used as a template as it was last in the list, before moving "updatesready" around where I saw it fit. Fixed and also removed it from IDS. thx grembo: IDS had, which was the one I used as a template as it was last in the list, before moving… | |||||
install -- Install downloaded updates or upgrades | install -- Install downloaded updates or upgrades | ||||
Done Inline ActionsNot completely sure about the order of these, but not a new problem in your patch. emaste: Not completely sure about the order of these, but not a new problem in your patch. | |||||
Done Inline ActionsI think they're ordered based on when they're executed - first fetch updates (by using fetch/cron for simple stuff and upgrade for major releases), then check if there is anything to install (updatesready), then install them. If something went wrong, do a rollback. Run IDS regularily and config for debugging. grembo: I think they're ordered based on when they're executed - first fetch updates (by using… | |||||
Done Inline ActionsBased on my own reasoning one could argue that `showconfig' should be first in the list, as you might want to check what's configured before doing anything else. Then again, as it's *last*, it's really easy to spot on help. So in the end this probably doesn't really matter that much. grembo: Based on my own reasoning one could argue that `showconfig' should be first in the list, as you… | |||||
rollback -- Uninstall most recently installed updates | rollback -- Uninstall most recently installed updates | ||||
IDS -- Compare the system against an index of "known good" files | IDS -- Compare the system against an index of "known good" files | ||||
showconfig -- Show configuration | |||||
Done Inline ActionsCommitted this part in rS352514 emaste: Committed this part in rS352514 | |||||
EOF | EOF | ||||
exit 0 | exit 0 | ||||
} | } | ||||
#### Configuration processing functions | #### Configuration processing functions | ||||
#- | #- | ||||
# Configuration options are set in the following order of priority: | # Configuration options are set in the following order of priority: | ||||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | while [ $# -gt 0 ]; do | ||||
--debug) | --debug) | ||||
config_VerboseLevel debug || usage | config_VerboseLevel debug || usage | ||||
;; | ;; | ||||
--no-stats) | --no-stats) | ||||
config_VerboseLevel nostats || usage | config_VerboseLevel nostats || usage | ||||
;; | ;; | ||||
# Commands | # Commands | ||||
cron | fetch | upgrade | install | rollback | IDS) | cron | fetch | upgrade | updatesready | install | rollback |\ | ||||
IDS | showconfig) | |||||
COMMANDS="${COMMANDS} $1" | COMMANDS="${COMMANDS} $1" | ||||
;; | ;; | ||||
# Anything else is an error | # Anything else is an error | ||||
*) | *) | ||||
usage | usage | ||||
;; | ;; | ||||
esac | esac | ||||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | install_check_params () { | ||||
# Construct a unique name from ${BASEDIR} | # Construct a unique name from ${BASEDIR} | ||||
BDHASH=`echo ${BASEDIR} | sha256 -q` | BDHASH=`echo ${BASEDIR} | sha256 -q` | ||||
# Check that we have updates ready to install | # Check that we have updates ready to install | ||||
if ! [ -L ${BDHASH}-install ]; then | if ! [ -L ${BDHASH}-install ]; then | ||||
echo "No updates are available to install." | echo "No updates are available to install." | ||||
if [ $ISFETCHED -eq 0 ]; then | if [ $ISFETCHED -eq 0 ]; then | ||||
echo "Run '$0 fetch' first." | echo "Run '$0 fetch' first." | ||||
exit 1 | exit 2 | ||||
fi | fi | ||||
exit 0 | exit 0 | ||||
fi | fi | ||||
if ! [ -f ${BDHASH}-install/INDEX-OLD ] || | if ! [ -f ${BDHASH}-install/INDEX-OLD ] || | ||||
! [ -f ${BDHASH}-install/INDEX-NEW ]; then | ! [ -f ${BDHASH}-install/INDEX-NEW ]; then | ||||
echo "Update manifest is corrupt -- this should never happen." | echo "Update manifest is corrupt -- this should never happen." | ||||
echo "Re-run '$0 fetch'." | echo "Re-run '$0 fetch'." | ||||
exit 1 | exit 1 | ||||
▲ Show 20 Lines • Show All 2,489 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
# Fetch files for upgrading to a new release. | # Fetch files for upgrading to a new release. | ||||
cmd_upgrade () { | cmd_upgrade () { | ||||
upgrade_check_params | upgrade_check_params | ||||
upgrade_run || exit 1 | upgrade_run || exit 1 | ||||
} | } | ||||
# Check if there are fetched updates ready to install | |||||
cmd_updatesready () { | |||||
# Construct a unique name from ${BASEDIR} | |||||
BDHASH=`echo ${BASEDIR} | sha256 -q` | |||||
# Check that we have updates ready to install | |||||
if ! [ -L ${BDHASH}-install ]; then | |||||
echo "No updates are available to install." | |||||
exit 2 | |||||
fi | |||||
echo "There are updates available to install." | |||||
echo "Run '$0 install' to proceed." | |||||
Done Inline Actionsnit: closing single quote seems to be farther that needed, '$0 install' yuripv: nit: closing single quote seems to be farther that needed, '$0 install' | |||||
Done Inline Actionsthx grembo: thx | |||||
} | |||||
# Install downloaded updates. | # Install downloaded updates. | ||||
cmd_install () { | cmd_install () { | ||||
install_check_params | install_check_params | ||||
install_run || exit 1 | install_run || exit 1 | ||||
} | } | ||||
# Rollback most recently installed updates. | # Rollback most recently installed updates. | ||||
cmd_rollback () { | cmd_rollback () { | ||||
rollback_check_params | rollback_check_params | ||||
rollback_run || exit 1 | rollback_run || exit 1 | ||||
} | } | ||||
# Compare system against a "known good" index. | # Compare system against a "known good" index. | ||||
cmd_IDS () { | cmd_IDS () { | ||||
IDS_check_params | IDS_check_params | ||||
IDS_run || exit 1 | IDS_run || exit 1 | ||||
} | |||||
# Output configuration. | |||||
cmd_showconfig () { | |||||
for X in ${CONFIGOPTIONS}; do | |||||
echo $X=$(eval echo \$${X}) | |||||
done | |||||
} | } | ||||
#### Entry point | #### Entry point | ||||
# Make sure we find utilities from the base system | # Make sure we find utilities from the base system | ||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH} | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH} | ||||
# Set a pager if the user doesn't | # Set a pager if the user doesn't | ||||
Show All 11 Lines |
nit: other commands don't have trailing dot (same for config) except for IDS, doesn't look consistent