Skip to content
Snippets Groups Projects
Unverified Commit 60a5c7ca authored by Massimiliano Adamo's avatar Massimiliano Adamo
Browse files

add self-update option to shell script

parent b96faeef
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,6 @@ upload_linux_shell: ...@@ -25,7 +25,6 @@ upload_linux_shell:
stage: upload_linux_shell stage: upload_linux_shell
only: only:
- tags - tags
- branches
image: curlimages/curl:7.76.1 image: curlimages/curl:7.76.1
script: script:
- 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader.sh ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}.sh' - 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader.sh ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}.sh'
...@@ -36,7 +35,6 @@ upload_linux_amd64_binary: ...@@ -36,7 +35,6 @@ upload_linux_amd64_binary:
stage: upload_linux_amd64_binary stage: upload_linux_amd64_binary
only: only:
- tags - tags
- branches
script: script:
- ./build.sh --os=linux --arch=amd64 --version=$CI_COMMIT_TAG --upx - ./build.sh --os=linux --arch=amd64 --version=$CI_COMMIT_TAG --upx
- 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}_linux_amd64' - 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}_linux_amd64'
...@@ -47,7 +45,6 @@ upload_windows_amd64_binary: ...@@ -47,7 +45,6 @@ upload_windows_amd64_binary:
stage: upload_windows_amd64_binary stage: upload_windows_amd64_binary
only: only:
- tags - tags
- branches
script: script:
- ./build.sh --os=windows --arch=amd64 --version=$CI_COMMIT_TAG --upx - ./build.sh --os=windows --arch=amd64 --version=$CI_COMMIT_TAG --upx
- 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader.exe ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}_windows_amd64.exe' - 'curl -sSf -H "X-JFrog-Art-Api:${ARTIFACTORY_TOKEN}" -X PUT -T ./acme-downloader.exe ${ARTIFACTORY_BASE_URL}/${ARTIFACT_NAME}_windows_amd64.exe'
......
...@@ -66,7 +66,7 @@ usage() { ...@@ -66,7 +66,7 @@ usage() {
echo " --redis-token (Redis access token)" echo " --redis-token (Redis access token)"
echo " --vault-token (Vault access token)" echo " --vault-token (Vault access token)"
echo " --cert-name (Certificate name)" echo " --cert-name (Certificate name)"
echo " --team-name (Team name: swd, dream_team, it, ne, ti...)" echo " --team-name (Team name: swd, dream_team, it, ne, ti, nmaas...)"
echo " --days [OPTIONAL check days before expiration. Default: 30)" echo " --days [OPTIONAL check days before expiration. Default: 30)"
echo " --type [OPTIONAL. OV or EV. Default: EV]" echo " --type [OPTIONAL. OV or EV. Default: EV]"
echo " --cert-destination [OPTIONAL Default: ${CERT_BASE}/<cert-name>.crt]" echo " --cert-destination [OPTIONAL Default: ${CERT_BASE}/<cert-name>.crt]"
...@@ -74,6 +74,7 @@ usage() { ...@@ -74,6 +74,7 @@ usage() {
echo " --key-destination [OPTIONAL Default: ${KEY_BASE}/<cert-name>.key]" echo " --key-destination [OPTIONAL Default: ${KEY_BASE}/<cert-name>.key]"
echo " --ca-destination [OPTIONAL Default: ${CERT_BASE}/COMODO_<type>.crt]" echo " --ca-destination [OPTIONAL Default: ${CERT_BASE}/COMODO_<type>.crt]"
echo " --wildcard [OPTIONAL if the certificate is wildcard]" echo " --wildcard [OPTIONAL if the certificate is wildcard]"
echo " --update [OPTIONAL self-updates the script and exit]"
echo "" echo ""
clean_up clean_up
} }
...@@ -130,6 +131,9 @@ while true; do ...@@ -130,6 +131,9 @@ while true; do
--wildcard) --wildcard)
WILDCARD='WILDCARD' WILDCARD='WILDCARD'
;; ;;
--update)
UPDATE='UPDATE'
;;
--) --)
shift shift
break break
...@@ -140,6 +144,18 @@ done ...@@ -140,6 +144,18 @@ done
TYPE=$(echo $TYPE | tr '[:lower:]' '[:upper:]') TYPE=$(echo $TYPE | tr '[:lower:]' '[:upper:]')
if [ -n $UPDATE ]; then
curl $SCRIPT_URL -o $0
UPDATE_STATUS=$?
if [ $UPDATE_STATUS == 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
exit $UPDATE_STATUS
fi
if [[ -z $REDIS_TOKEN ]] || [[ -z $VAULT_TOKEN ]] || [[ -z $CERT_NAME ]] || [[ -z $TEAM_NAME ]]; then if [[ -z $REDIS_TOKEN ]] || [[ -z $VAULT_TOKEN ]] || [[ -z $CERT_NAME ]] || [[ -z $TEAM_NAME ]]; then
echo -e "\n--redis-token, --vault-token, --cert-name and --team-name are mandatory\n" echo -e "\n--redis-token, --vault-token, --cert-name and --team-name 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