rc: let opnsense-version -c check package file existence

This commit is contained in:
Franco Fichtner 2021-02-05 13:26:43 +01:00
parent 53556813e4
commit 12637eb7f5
3 changed files with 25 additions and 6 deletions

View File

@ -1,5 +1,5 @@
.\"
.\" Copyright (c) 2018 Franco Fichtner <franco@opnsense.org>
.\" Copyright (c) 2018-2021 Franco Fichtner <franco@opnsense.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd December 11, 2018
.Dd February 5, 2021
.Dt OPNSENSE-VERSION 8
.Os
.Sh NAME
@ -34,6 +34,9 @@
.Nm
.Op Fl AaefHNnsvw
.Op Ar package
.Nm
.Fl c
.Op Ar package
.Sh DESCRIPTION
The
.Nm
@ -64,6 +67,9 @@ The options are as follows:
Return the system architecture string.
.It Fl a
Return the firmware ABI string.
.It Fl c
Exit successfully if the package exists.
Otherwise, exit with an error.
.It Fl e
Return the product contact e-mail address.
.It Fl f

View File

@ -29,7 +29,7 @@ PLUGIN=${1}
RETURN="0"
# Return "1" if the plugin is installed (stable or development).
if [ -f "/usr/local/opnsense/version/${PLUGIN}" ]; then
if opnsense-version -c "${PLUGIN}"; then
RETURN="1"
fi

View File

@ -30,7 +30,9 @@ PKG="/usr/local/sbin/pkg-static"
TARGET="core"
OUTPUT=
while getopts AaefHNnsvw OPT; do
DO_CHECK=
while getopts AacefHNnsvw OPT; do
case ${OPT} in
A)
OUTPUT="${OUTPUT} \${product_arch}"
@ -38,6 +40,9 @@ while getopts AaefHNnsvw OPT; do
a)
OUTPUT="${OUTPUT} \${product_abi}"
;;
c)
DO_CHECK="-c"
;;
e)
OUTPUT="${OUTPUT} \${product_email}"
;;
@ -76,13 +81,21 @@ if [ -n "${1}" ]; then
shift
fi
VERSION="${VERSIONDIR}/${TARGET}"
if [ -n "${DO_CHECK}" ]; then
RET=0
if [ ! -f ${VERSION} ]; then
RET=1
fi
exit ${RET}
fi
if [ -n "${*}" ]; then
echo "Additional arguments are not supported" >&2
exit 1
fi
VERSION="${VERSIONDIR}/${TARGET}"
if [ ! -f ${VERSION} ]; then
echo "Missing ${VERSION}" >&2
exit 1