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

overwrite file only if download succeeded

parent e64ff3c1
No related branches found
No related tags found
No related merge requests found
Pipeline #74678 passed
...@@ -184,9 +184,10 @@ check_version ...@@ -184,9 +184,10 @@ check_version
VERSION_STATUS=$? VERSION_STATUS=$?
if [[ -n $FORCE_UPDATE ]]; then if [[ -n $FORCE_UPDATE ]]; then
curl $SCRIPT_URL -o $0 curl $SCRIPT_URL -o ${0}.new
UPDATE_STATUS=$? UPDATE_STATUS=$?
if [ $UPDATE_STATUS == 0 ]; then if [ $UPDATE_STATUS == 0 ]; then
rm -f $0; mv ${0}.new $0; chmod 0755 $0
echo -e "\n$0 updated successfully\n" echo -e "\n$0 updated successfully\n"
else else
echo -e "\nfailed to update $0" echo -e "\nfailed to update $0"
...@@ -198,7 +199,7 @@ fi ...@@ -198,7 +199,7 @@ fi
if [[ -n $UPDATE ]]; then if [[ -n $UPDATE ]]; then
UPDATE_STATUS="skip" UPDATE_STATUS="skip"
if [ $VERSION_STATUS -eq 1 ]; then if [ $VERSION_STATUS -eq 1 ]; then
curl $SCRIPT_URL -o $0 curl $SCRIPT_URL -o ${0}.new
UPDATE_STATUS=$? UPDATE_STATUS=$?
fi fi
if [ $UPDATE_STATUS == "skip" ]; then if [ $UPDATE_STATUS == "skip" ]; then
...@@ -206,6 +207,7 @@ if [[ -n $UPDATE ]]; then ...@@ -206,6 +207,7 @@ if [[ -n $UPDATE ]]; then
echo -e "\n$0 is already up to date\n" echo -e "\n$0 is already up to date\n"
elif [ $UPDATE_STATUS -eq 0 ]; then elif [ $UPDATE_STATUS -eq 0 ]; then
EXIT_STATUS=0 EXIT_STATUS=0
rm -f $0; mv ${0}.new $0; chmod 0755 $0
echo -e "\n$0 updated successfully\n" echo -e "\n$0 updated successfully\n"
else else
EXIT_STATUS=$UPDATE_STATUS EXIT_STATUS=$UPDATE_STATUS
...@@ -215,7 +217,6 @@ if [[ -n $UPDATE ]]; then ...@@ -215,7 +217,6 @@ if [[ -n $UPDATE ]]; then
clean_up $EXIT_STATUS clean_up $EXIT_STATUS
fi fi
if [[ -z $REDIS_TOKEN ]] || [[ -z $VAULT_TOKEN ]] || [[ -z $CERT_NAME ]] || [[ -z $TEAM_NAME ]] || [[ -z $TYPE ]]; then 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" echo -e "\n--redis-token, --vault-token, --cert-name, --team-name and --type are mandatory\n"
usage usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment