Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show All 37 Lines | |||||
Options: | Options: | ||||
-b basedir -- Operate on a system mounted at basedir | -b basedir -- Operate on a system mounted at basedir | ||||
(default: /) | (default: /) | ||||
-d workdir -- Store working files in workdir | -d workdir -- Store working files in workdir | ||||
(default: /var/db/freebsd-update/) | (default: /var/db/freebsd-update/) | ||||
-f conffile -- Read configuration options from conffile | -f conffile -- Read configuration options from conffile | ||||
(default: /etc/freebsd-update.conf) | (default: /etc/freebsd-update.conf) | ||||
-F -- Force a fetch operation to proceed | |||||
-k KEY -- Trust an RSA key with SHA256 hash of KEY | -k KEY -- Trust an RSA key with SHA256 hash of KEY | ||||
-r release -- Target for upgrade (e.g., 6.2-RELEASE) | -r release -- Target for upgrade (e.g., 6.2-RELEASE) | ||||
-s server -- Server from which to fetch updates | -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 | |||||
-- Run without a tty, for use by automated tools | |||||
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 | ||||
install -- Install downloaded updates or upgrades | install -- Install downloaded updates or upgrades | ||||
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. | ||||
▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | init_params () { | ||||
# Configration settings | # Configration settings | ||||
nullconfig | nullconfig | ||||
# No configuration file set yet | # No configuration file set yet | ||||
CONFFILE="" | CONFFILE="" | ||||
# No commands specified yet | # No commands specified yet | ||||
COMMANDS="" | COMMANDS="" | ||||
# Force fetch to proceed | |||||
FORCEFETCH=0 | |||||
# Run without a TTY | |||||
NOTTYOK=0 | |||||
} | } | ||||
# Parse the command line | # Parse the command line | ||||
parse_cmdline () { | parse_cmdline () { | ||||
while [ $# -gt 0 ]; do | while [ $# -gt 0 ]; do | ||||
case "$1" in | case "$1" in | ||||
# Location of configuration file | # Location of configuration file | ||||
-f) | -f) | ||||
if [ $# -eq 1 ]; then usage; fi | if [ $# -eq 1 ]; then usage; fi | ||||
if [ ! -z "${CONFFILE}" ]; then usage; fi | if [ ! -z "${CONFFILE}" ]; then usage; fi | ||||
shift; CONFFILE="$1" | shift; CONFFILE="$1" | ||||
;; | ;; | ||||
-F) | |||||
FORCEFETCH=1 | |||||
;; | |||||
--not-running-from-cron) | |||||
NOTTYOK=1 | |||||
;; | |||||
# Configuration file equivalents | # Configuration file equivalents | ||||
-b) | -b) | ||||
if [ $# -eq 1 ]; then usage; fi; shift | if [ $# -eq 1 ]; then usage; fi; shift | ||||
config_BaseDir $1 || usage | config_BaseDir $1 || usage | ||||
;; | ;; | ||||
-d) | -d) | ||||
if [ $# -eq 1 ]; then usage; fi; shift | if [ $# -eq 1 ]; then usage; fi; shift | ||||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | fetch_check_params () { | ||||
fetchupgrade_check_params | fetchupgrade_check_params | ||||
if ! [ -z "${TARGETRELEASE}" ]; then | if ! [ -z "${TARGETRELEASE}" ]; then | ||||
echo -n "`basename $0`: " | echo -n "`basename $0`: " | ||||
echo -n "-r option is meaningless with 'fetch' command. " | echo -n "-r option is meaningless with 'fetch' command. " | ||||
echo "(Did you mean 'upgrade' instead?)" | echo "(Did you mean 'upgrade' instead?)" | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
# Check that we have updates ready to install | |||||
if [ -f ${BDHASH}-install/kerneldone && $FORCEFETCH -eq 0 ]; then | |||||
allanjude: This is probably not a smart enough check.
We only want to block 'fetch' if there is an in… | |||||
echo "You have a partially completed upgrade pending" | |||||
echo "Run '$0 install' first." | |||||
echo "Run '$0 fetch -F' to proceed anyway." | |||||
exit 1 | |||||
fi | |||||
} | } | ||||
# Perform sanity checks etc. before fetching upgrades. | # Perform sanity checks etc. before fetching upgrades. | ||||
upgrade_check_params () { | upgrade_check_params () { | ||||
fetchupgrade_check_params | fetchupgrade_check_params | ||||
# Unless set otherwise, we're upgrading to the same kernel config. | # Unless set otherwise, we're upgrading to the same kernel config. | ||||
NKERNCONF=${KERNCONF} | NKERNCONF=${KERNCONF} | ||||
▲ Show 20 Lines • Show All 2,499 Lines • ▼ Show 20 Lines | get_params () { | ||||
parse_cmdline $@ | parse_cmdline $@ | ||||
parse_conffile | parse_conffile | ||||
default_params | default_params | ||||
} | } | ||||
# Fetch command. Make sure that we're being called | # Fetch command. Make sure that we're being called | ||||
# interactively, then run fetch_check_params and fetch_run | # interactively, then run fetch_check_params and fetch_run | ||||
cmd_fetch () { | cmd_fetch () { | ||||
if [ ! -t 0 ]; then | if [ ! -t 0 && $NOTTYOK -eq 0 ]; then | ||||
echo -n "`basename $0` fetch should not " | echo -n "`basename $0` fetch should not " | ||||
echo "be run non-interactively." | echo "be run non-interactively." | ||||
echo "Run `basename $0` cron instead." | echo "Run `basename $0` cron instead." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
fetch_check_params | fetch_check_params | ||||
fetch_run || exit 1 | fetch_run || exit 1 | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
This is probably not a smart enough check.
We only want to block 'fetch' if there is an in-progress 'upgrade' going on. Where the user has installed a new kernel, but has not finished installing the new world yet.