aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/freebsd-update/freebsd-update.sh
diff options
context:
space:
mode:
authorAllan Jude <allanjude@FreeBSD.org>2015-03-03 23:20:18 +0000
committerAllan Jude <allanjude@FreeBSD.org>2015-03-03 23:20:18 +0000
commit8935f2425141e6db765e60402112b519f20358b5 (patch)
tree4020f25a655e7063953c19432cffa901496a7606 /usr.sbin/freebsd-update/freebsd-update.sh
parent5090c893b72d26193d4d4c923efe3affafbb3f4b (diff)
downloadsrc-8935f2425141e6db765e60402112b519f20358b5.tar.gz
src-8935f2425141e6db765e60402112b519f20358b5.zip
Add a new safetly belt to freebsd-update to prevent a user doing a minor update (-pX) while having an unfinished major upgrade (9.x to 9.y)
Safetly belt can be disabled with the -F flag Additionally, add the --not-running-from-cron flag they bypasses the TTY requirement, and allows freebsd-update to be invoked by orchestration frameworks, scripts, or otherwise. PR: 196760 Differential Revision: https://reviews.freebsd.org/D1550 Reviewed by: cperciva, delphij Approved by: bcr (mentor), rodrigc (src) MFC after: 1 month Relnotes: yes Sponsored by: ScaleEngine Inc.
Notes
Notes: svn path=/head/; revision=279571
Diffstat (limited to 'usr.sbin/freebsd-update/freebsd-update.sh')
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh25
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index c3a7e5f03321..4c8891f6b03e 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -43,12 +43,15 @@ Options:
(default: /var/db/freebsd-update/)
-f conffile -- Read configuration options from conffile
(default: /etc/freebsd-update.conf)
+ -F -- Force a fetch operation to proceed
-k KEY -- Trust an RSA key with SHA256 hash of KEY
-r release -- Target for upgrade (e.g., 6.2-RELEASE)
-s server -- Server from which to fetch updates
(default: update.FreeBSD.org)
-t address -- Mail output of cron command, if any, to address
(default: root)
+ --not-running-from-cron
+ -- Run without a tty, for use by automated tools
Commands:
fetch -- Fetch updates from server
cron -- Sleep rand(3600) seconds, fetch updates, and send an
@@ -399,6 +402,12 @@ init_params () {
# No commands specified yet
COMMANDS=""
+
+ # Force fetch to proceed
+ FORCEFETCH=0
+
+ # Run without a TTY
+ NOTTYOK=0
}
# Parse the command line
@@ -411,6 +420,12 @@ parse_cmdline () {
if [ ! -z "${CONFFILE}" ]; then usage; fi
shift; CONFFILE="$1"
;;
+ -F)
+ FORCEFETCH=1
+ ;;
+ --not-running-from-cron)
+ NOTTYOK=1
+ ;;
# Configuration file equivalents
-b)
@@ -673,6 +688,14 @@ fetch_check_params () {
echo "(Did you mean 'upgrade' instead?)"
exit 1
fi
+
+ # Check that we have updates ready to install
+ if [ -f ${BDHASH}-install/kerneldone && $FORCEFETCH -eq 0 ]; then
+ 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.
@@ -3197,7 +3220,7 @@ get_params () {
# Fetch command. Make sure that we're being called
# interactively, then run fetch_check_params and fetch_run
cmd_fetch () {
- if [ ! -t 0 ]; then
+ if [ ! -t 0 && $NOTTYOK -eq 0 ]; then
echo -n "`basename $0` fetch should not "
echo "be run non-interactively."
echo "Run `basename $0` cron instead."