Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show All 30 Lines | |||||
#### Usage function -- called from command-line handling code. | #### Usage function -- called from command-line handling code. | ||||
# Usage instructions. Options not listed: | # Usage instructions. Options not listed: | ||||
# --debug -- don't filter output from utilities | # --debug -- don't filter output from utilities | ||||
# --no-stats -- don't show progress statistics while fetching files | # --no-stats -- don't show progress statistics while fetching files | ||||
usage () { | usage () { | ||||
cat <<EOF | cat <<EOF | ||||
usage: `basename $0` [options] command ... [path] | usage: `basename $0` [options] command ... | ||||
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 in the | -F -- Force a fetch operation to proceed in the | ||||
case of an unfinished upgrade | case of an unfinished upgrade | ||||
-j jail -- Operate on the given jail specified by jid or name | |||||
-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., 11.1-RELEASE) | -r release -- Target for upgrade (e.g., 11.1-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 | --not-running-from-cron | ||||
-- Run without a tty, for use by automated tools | -- Run without a tty, for use by automated tools | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | |||||
config_SourceRelease () { | config_SourceRelease () { | ||||
UNAME_r=$1 | UNAME_r=$1 | ||||
if echo ${UNAME_r} | grep -qE '^[0-9.]+$'; then | if echo ${UNAME_r} | grep -qE '^[0-9.]+$'; then | ||||
UNAME_r="${UNAME_r}-RELEASE" | UNAME_r="${UNAME_r}-RELEASE" | ||||
fi | fi | ||||
export UNAME_r | export UNAME_r | ||||
} | } | ||||
# Get the Jail's path and the version of its installed userland | |||||
config_TargetJail () { | |||||
JAIL=$1 | |||||
UNAME_r=$(freebsd-version -j ${JAIL}) | |||||
BASEDIR=$(jls -j ${JAIL} -h path | awk 'NR == 2 {print}') | |||||
dteske: I would use NR instead of FNR here simply because FNR has the additional complexity that it… | |||||
if [ -z ${BASEDIR} ] || [ -z ${UNAME_r} ]; then | |||||
echo "The specified jail either doesn't exist or" \ | |||||
"does not have freebsd-version." | |||||
exit 1 | |||||
fi | |||||
export UNAME_r | |||||
} | |||||
# Define what happens to output of utilities | # Define what happens to output of utilities | ||||
config_VerboseLevel () { | config_VerboseLevel () { | ||||
if [ -z ${VERBOSELEVEL} ]; then | if [ -z ${VERBOSELEVEL} ]; then | ||||
case $1 in | case $1 in | ||||
[Dd][Ee][Bb][Uu][Gg]) | [Dd][Ee][Bb][Uu][Gg]) | ||||
VERBOSELEVEL=debug | VERBOSELEVEL=debug | ||||
;; | ;; | ||||
[Nn][Oo][Ss][Tt][Aa][Tt][Ss]) | [Nn][Oo][Ss][Tt][Aa][Tt][Ss]) | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | while [ $# -gt 0 ]; do | ||||
# 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 | ||||
config_WorkDir $1 || usage | config_WorkDir $1 || usage | ||||
;; | |||||
-j) | |||||
if [ $# -eq 1 ]; then usage; fi; shift | |||||
config_TargetJail $1 || usage | |||||
;; | ;; | ||||
-k) | -k) | ||||
if [ $# -eq 1 ]; then usage; fi; shift | if [ $# -eq 1 ]; then usage; fi; shift | ||||
config_KeyPrint $1 || usage | config_KeyPrint $1 || usage | ||||
;; | ;; | ||||
-s) | -s) | ||||
if [ $# -eq 1 ]; then usage; fi; shift | if [ $# -eq 1 ]; then usage; fi; shift | ||||
config_ServerName $1 || usage | config_ServerName $1 || usage | ||||
▲ Show 20 Lines • Show All 2,966 Lines • Show Last 20 Lines |
I would use NR instead of FNR here simply because FNR has the additional complexity that it will reset to 1 when working on the next file, but when used to process a pipe stream it is in-essence working on a single file (/dev/stdin) and thus NR and FNR are always aligned making the use of FNR a bit of a bogon