diff --git a/src/man/man8/opnsense-version.8 b/src/man/man8/opnsense-version.8 index 40d0e6b53..e9bd2256d 100644 --- a/src/man/man8/opnsense-version.8 +++ b/src/man/man8/opnsense-version.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd Sep 16, 2018 +.Dd Sep 17, 2018 .Dt OPNSENSE-VERSION 8 .Os .Sh NAME @@ -48,6 +48,7 @@ It is similar to .Sq Fl a parameter, but not intended to handle operating system information. .Pp +Multiple options can be specified to build a custom version string. The options are as follows: .Bl -tag -width ".Fl a" -offset indent .It Fl a @@ -56,8 +57,6 @@ Return the firmware ABI string. Return the product name. .It Fl n Return the release package name. -.It Fl V -Return the product name followed by its version. .It Fl v Return the release package version. .El diff --git a/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php b/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php index d71c3de8a..924c85eec 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php +++ b/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php @@ -56,7 +56,7 @@ abstract class Base @unlink("{$file}.dec"); if (file_exists("{$file}.enc")) { - $version = trim(shell_exec('opnsense-version -V')); + $version = trim(shell_exec('opnsense-version -Nv')); $result = "---- BEGIN {$tag} ----\n"; $result .= "Version: {$version}\n"; $result .= "Cipher: AES-256-CBC\n"; diff --git a/src/sbin/opnsense-version b/src/sbin/opnsense-version index 7d2b8631d..2b0e81907 100755 --- a/src/sbin/opnsense-version +++ b/src/sbin/opnsense-version @@ -23,37 +23,41 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -PATTERN="s:[^\"]*\"\([^\"]*\)\"[^\"]*\"\([^\"]*\)\".*:\1=\2:" VERSION="/usr/local/opnsense/version/opnsense" +OUTPUT= if [ ! -f ${VERSION} ]; then echo "Missing ${VERSION}" >&2 exit 1 fi + eval "$(grep -v '[{}]' ${VERSION} | sed 's/[^"]*"\([^"]*\)"[^"]*"\([^"]*\)".*/\1="\2"/')" while getopts aNnVv OPT; do case ${OPT} in a) - echo ${product_abi} - exit 0 + if [ -n "${OUTPUT}" ]; then + OUTPUT="${OUTPUT} " + fi + OUTPUT="${OUTPUT}\${product_abi}" ;; N) - echo ${product_name} - exit 0 + if [ -n "${OUTPUT}" ]; then + OUTPUT="${OUTPUT} " + fi + OUTPUT="${OUTPUT}\${product_name}" ;; n) - echo ${product_id} - exit 0 - ;; - V) - # XXX replace with -Nv - echo "${product_name} ${product_version}" - exit 0 + if [ -n "${OUTPUT}" ]; then + OUTPUT="${OUTPUT} " + fi + OUTPUT="${OUTPUT}\${product_id}" ;; v) - echo ${product_version} - exit 0 + if [ -n "${OUTPUT}" ]; then + OUTPUT="${OUTPUT} " + fi + OUTPUT="${OUTPUT}\${product_version}" ;; *) echo "Usage: man opnsense-version" >&2 @@ -64,4 +68,8 @@ done shift $((${OPTIND} - 1)) -echo "${product_name} ${product_version} (${product_arch}/${product_flavour})" +if [ -z "${OUTPUT}" ]; then + OUTPUT="\${product_name} \${product_version} \(\${product_arch}/\${product_flavour}\)" +fi + +eval echo ${OUTPUT}