Skip to content
Snippets Groups Projects
Unverified Commit 4df2515d authored by Max Adamo's avatar Max Adamo
Browse files

add force-update option

parent 991f1b34
No related branches found
Tags v1.2.6
No related merge requests found
Pipeline #74672 passed
......@@ -50,6 +50,7 @@ check_version() {
echo "$(basename $0) $REMOTE_VERSION is available"
echo "to install the new version you can run: $(basename $0) --update"
echo ""
return 1
else
if [[ -n $CHECK ]]; then
echo "you are running the latest version"
......@@ -95,12 +96,13 @@ usage() {
echo " --ca-destination [OPTIONAL Default: ${CERT_BASE}/COMODO_<type>.crt]"
echo " --wildcard [OPTIONAL if the certificate is wildcard]"
echo " --check-version [OPTIONAL check difference with upstream exit]"
echo " --update [OPTIONAL self-updates the script and exit]"
echo " --update [OPTIONAL self-updates the script if a new version is available and exit]"
echo " --force-update [OPTIONAL always self-updates the script and exit]"
echo ""
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,version,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,force-update,version,wildcard" -- "$@")
eval set -- "$OPTS"
while true; do
......@@ -154,6 +156,9 @@ while true; do
--update)
UPDATE='UPDATE'
;;
--force-update)
FORCE_UPDATE='FORCE_UPDATE'
;;
--check-version)
CHECK='CHECK'
;;
......@@ -176,8 +181,9 @@ fi
# check if we are using the latest version
check_version
VERSION_STATUS=$?
if [[ -n $UPDATE ]]; then
if [[ -n $FORCE_UPDATE ]]; then
curl $SCRIPT_URL -o $0
UPDATE_STATUS=$?
if [ $UPDATE_STATUS == 0 ]; then
......@@ -189,6 +195,24 @@ if [[ -n $UPDATE ]]; then
clean_up $UPDATE_STATUS
fi
if [[ -n $UPDATE ]]; then
UPDATE_STATUS="skip"
if [ $VERSION_STATUS -eq 1 ]; then
curl $SCRIPT_URL -o $0
UPDATE_STATUS=$?
fi
if [ $UPDATE_STATUS == "skip" ]; then
echo -e "\n$0 is already up to date\n"
elif [ $UPDATE_STATUS -eq 0 ]; then
echo -e "\n$0 updated successfully\n"
else
echo -e "\nfailed to update $0"
echo -e "Please download the script manually from this URL: ${SCRIPT_URL}\n"
fi
clean_up $UPDATE_STATUS
fi
if [[ -z $REDIS_TOKEN ]] || [[ -z $VAULT_TOKEN ]] || [[ -z $CERT_NAME ]] || [[ -z $TEAM_NAME ]] || [[ -z $TYPE ]]; then
echo -e "\n--redis-token, --vault-token, --cert-name, --team-name and --type are mandatory\n"
usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment