freebsd-version(1): Add -j flag to support jails
Make freebsd-version(1) support jails by adding the -j flag which takes a jail jid or name as an argument. As with other options, -j flags stack and display in the order requested. Reviewed by: bcr (manpages), kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25705
This commit is contained in:
parent
2f4dbe279f
commit
f54b18fc4d
@ -25,7 +25,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 14, 2017
|
.Dd October 1, 2021
|
||||||
.Dt FREEBSD-VERSION 1
|
.Dt FREEBSD-VERSION 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -34,6 +34,7 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl kru
|
.Op Fl kru
|
||||||
|
.Op Fl j Ar jail
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
@ -60,12 +61,20 @@ Print the version and patch level of the installed userland.
|
|||||||
These are hardcoded into
|
These are hardcoded into
|
||||||
.Nm
|
.Nm
|
||||||
during the build.
|
during the build.
|
||||||
|
.It Fl j Ar jail
|
||||||
|
Print the version and patch level of the installed userland in the
|
||||||
|
given jail specified by
|
||||||
|
.Va jid
|
||||||
|
or
|
||||||
|
.Va name .
|
||||||
|
This option can be specified multiple times.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
If several of the above options are specified,
|
If several of the above options are specified,
|
||||||
.Nm
|
.Nm
|
||||||
will print the installed kernel version first, then the running kernel
|
will print the installed kernel version first, then the running kernel
|
||||||
version, and finally the userland version, on separate lines.
|
version, next the userland version, and finally the userland version
|
||||||
|
of the specified jails, on separate lines.
|
||||||
If neither is specified, it will print the userland version only.
|
If neither is specified, it will print the userland version only.
|
||||||
.Sh IMPLEMENTATION NOTES
|
.Sh IMPLEMENTATION NOTES
|
||||||
The
|
The
|
||||||
|
@ -84,11 +84,20 @@ userland_version() {
|
|||||||
echo $USERLAND_VERSION
|
echo $USERLAND_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Print the hardcoded userland version of a jail.
|
||||||
|
#
|
||||||
|
jail_version() {
|
||||||
|
for i in $jail; do
|
||||||
|
jexec -- $i freebsd-version
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Print a usage string and exit.
|
# Print a usage string and exit.
|
||||||
#
|
#
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $progname [-kru]" >&2
|
echo "usage: $progname [-kru] [-j jail]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +106,8 @@ usage() {
|
|||||||
#
|
#
|
||||||
main() {
|
main() {
|
||||||
# parse command-line arguments
|
# parse command-line arguments
|
||||||
while getopts "kru" option ; do
|
local OPTIND=1 OPTARG option
|
||||||
|
while getopts "kruj:" option ; do
|
||||||
case $option in
|
case $option in
|
||||||
k)
|
k)
|
||||||
opt_k=1
|
opt_k=1
|
||||||
@ -108,6 +118,14 @@ main() {
|
|||||||
u)
|
u)
|
||||||
opt_u=1
|
opt_u=1
|
||||||
;;
|
;;
|
||||||
|
j)
|
||||||
|
if [ $opt_j ] ; then
|
||||||
|
jail="$jail $OPTARG"
|
||||||
|
else
|
||||||
|
opt_j=1
|
||||||
|
jail="$OPTARG"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
@ -118,7 +136,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# default is -u
|
# default is -u
|
||||||
if [ $((opt_k + opt_r + opt_u)) -eq 0 ] ; then
|
if [ $((opt_k + opt_r + opt_u + opt_j)) -eq 0 ] ; then
|
||||||
opt_u=1
|
opt_u=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -136,6 +154,11 @@ main() {
|
|||||||
if [ $opt_u ] ; then
|
if [ $opt_u ] ; then
|
||||||
userland_version
|
userland_version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# print jail version
|
||||||
|
if [ $opt_j ] ; then
|
||||||
|
jail_version
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user