From 3e93f925d3f885df24a5e5c97bfa42a135abb2c5 Mon Sep 17 00:00:00 2001 From: Eric F Crist Date: Tue, 14 Apr 2020 19:10:07 -0500 Subject: [PATCH] Add version output option and info Now supports both --version and "version and outputs detailed version information. Tested on FreeBSD, macOS, and Windows 10 64-bit. Sample Output: EasyRSA Version Information Version: git-development Generated: Tue Apr 14 18:54:42 CDT 2020 SSL Lib: OpenSSL 1.1.1a-freebsd 20 Nov 2018 Git Commit: f0129cfe6222820a85db2d394ab73d3c7759c5be Source Repo: https://github.com/OpenVPN/easy-rsa This closes #372 Signed-off-by: Eric F Crist --- build/build-dist.sh | 13 ++++++++++++- easyrsa3/easyrsa | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/build/build-dist.sh b/build/build-dist.sh index 5436ea8..eeb762f 100755 --- a/build/build-dist.sh +++ b/build/build-dist.sh @@ -79,7 +79,11 @@ stage_unix() { done # FreeBSD does not accept -i without argument in a way also acceptable by GNU sed - sed -i.tmp -e "s/~VER~/$VERSION/" "$DIST_ROOT/unix/$PV/easyrsa" || die "Cannot update easyrsa version" + sed -i.tmp -e "s/~VER~/$VERSION/" \ + -e "s/~DATE~/$(date)/" \ + -e "s/~HOST~/$(hostname -s)/" \ + -e "s/~GITHEAD~/$(git rev-parse HEAD)/" \ + "$DIST_ROOT/unix/$PV/easyrsa" || die "Cannot update easyrsa version data" rm -f "$DIST_ROOT/unix/$PV/easyrsa.tmp" # files not included @@ -116,6 +120,13 @@ stage_win() { cp -R "$SRC_ROOT/distro/windows/$f" "$DIST_ROOT/$win/$PV/" || die "failed to copy $f" unix2dos "$DIST_ROOT/$win/$PV/$f" || die "unix2dos conversion failed for $f" done + + sed -i.tmp -e "s/~VER~/$VERSION/" \ + -e "s/~DATE~/$(date)/" \ + -e "s/~HOST~/$(hostname -s)/" \ + -e "s/~GITHEAD~/$(git rev-parse HEAD)/" \ + "$DIST_ROOT/$win/$PV/easyrsa" || die "Cannot update easyrsa version data" + rm -f "$DIST_ROOT/$win/$PV/easyrsa.tmp" # files not included rm -rf "$DIST_ROOT/$win/$PV/doc/TODO" || die "failed rm TODO" diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index 261336f..2e1250f 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -221,6 +221,7 @@ General options: --passout=ARG : set -passout ARG for openssl --pki-dir=DIR : declares the PKI directory --vars=FILE : define a specific 'vars' file to use for Easy-RSA config +--version : prints EasyRSA version and build information, then exits Certificate & Request options: (these impact cert/req field values) @@ -2319,6 +2320,18 @@ return 0 } # => up23_manage_upgrade_23 () +print_version() +{ + cat < print_version () ######################################## @@ -2398,6 +2411,9 @@ while :; do export EASYRSA_EXTRA_EXTS="\ $EASYRSA_EXTRA_EXTS subjectAltName = $val" ;; + --version) + print_version + ;; *) break ;; esac @@ -2498,6 +2514,9 @@ case "$cmd" in cmd_help "$1" exit 0 ;; + version) + print_version + ;; *) die "Unknown command '$cmd'. Run without commands for usage help." ;;