diff --git a/src/man/man8/opnsense-version.8 b/src/man/man8/opnsense-version.8 index ee3bd1f8f..c3b2e263a 100644 --- a/src/man/man8/opnsense-version.8 +++ b/src/man/man8/opnsense-version.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2018 Franco Fichtner +.\" Copyright (c) 2018-2021 Franco Fichtner .\" .\" 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 diff --git a/src/opnsense/scripts/firmware/plugin.sh b/src/opnsense/scripts/firmware/plugin.sh index ded63090e..d4fe45e30 100755 --- a/src/opnsense/scripts/firmware/plugin.sh +++ b/src/opnsense/scripts/firmware/plugin.sh @@ -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 diff --git a/src/sbin/opnsense-version b/src/sbin/opnsense-version index 7705a92a9..b28c0051d 100755 --- a/src/sbin/opnsense-version +++ b/src/sbin/opnsense-version @@ -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