From 3fafd559d79885ad10b363e60c6facc8f4519447 Mon Sep 17 00:00:00 2001
From: Massimiliano Adamo <maxadamo@gmail.com>
Date: Wed, 22 Sep 2021 23:12:59 +0200
Subject: [PATCH] add version paramter again

---
 acme-downloader.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/acme-downloader.sh b/acme-downloader.sh
index 3f96024..234cae3 100755
--- a/acme-downloader.sh
+++ b/acme-downloader.sh
@@ -100,7 +100,7 @@ usage() {
     clean_up 2
 }
 
-OPTS=$(getopt -o "h" --longoptions "help,redis-token:,vault-token:,cert-name:,team-name:,days:,type:,cert-destination:,fullchain-destination:,key-destination:,ca-destination:,check-version,update,wildcard" -- "$@")
+OPTS=$(getopt -o "h" --longoptions "help,redis-token:,vault-token:,cert-name:,team-name:,days:,type:,cert-destination:,fullchain-destination:,key-destination:,ca-destination:,check-version,update,version,wildcard" -- "$@")
 eval set -- "$OPTS"
 
 while true; do
@@ -157,6 +157,9 @@ while true; do
     --check-version)
         CHECK='CHECK'
         ;;
+    --version)
+        PROG_VERSION='PROG_VERSION'
+        ;;
     --)
         shift
         break
@@ -165,9 +168,14 @@ while true; do
     shift
 done
 
-TYPE=$(echo $TYPE | tr '[:lower:]' '[:upper:]')
+# print version buildtime and say goodbye
+if [[ -n $PROG_VERSION ]]; then
+    echo "$(basename $0) version $VERSION built on ${BUILDTIME}"
+    clean_up 0
+fi
 
-#check_version $0
+# check if we are using the latest version
+check_version
 
 if [[ -n $UPDATE ]]; then
     curl $SCRIPT_URL -o $0
@@ -186,6 +194,7 @@ if [[ -z $REDIS_TOKEN ]] || [[ -z $VAULT_TOKEN ]] || [[ -z $CERT_NAME ]] || [[ -
     usage
 fi
 
+TYPE=$(echo $TYPE | tr '[:lower:]' '[:upper:]')
 [[ -z $TYPE ]] && TYPE="EV" # let's default to EV type
 if [[ $TYPE != "EV" ]] && [[ $TYPE != "OV" ]]; then
     echo "type must be either EV, ev, OV, ov"
-- 
GitLab