Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Acme Downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Geant DevOps
Acme Downloader
Commits
e082f404
Unverified
Commit
e082f404
authored
3 years ago
by
Massimiliano Adamo
Browse files
Options
Downloads
Patches
Plain Diff
add check version to shell script
parent
a22892f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
acme-downloader.sh
+31
-11
31 additions, 11 deletions
acme-downloader.sh
with
31 additions
and
11 deletions
acme-downloader.sh
+
31
−
11
View file @
e082f404
...
...
@@ -7,15 +7,6 @@
# the certificate will be checked, if it is valid, if the key matches
# and if it contains at least the cert-name
#
LOCAL_MD5
=
$(
md5sum
$0
|
awk
'{print $1}'
)
SCRIPT_URL
=
"https://artifactory.software.geant.org/artifactory/acme-downloader/acme-downloader.sh"
REMOTE_MD5
=
$(
curl
-s
$SCRIPT_URL
|
md5sum
|
awk
'{print $1}'
)
if
[[
$LOCAL_MD5
!=
$REMOTE_MD5
]]
;
then
echo
"
$0
differs from
$SCRIPT_URL
"
echo
"suggesting that you are running an older version"
echo
""
fi
REDIS_URL
=
"https://redis.geant.org/GET"
VAULT_URL
=
"https://vault.geant.org/v1"
TMP_CERT
=
$(
mktemp
)
...
...
@@ -38,11 +29,35 @@ trap 'clean_up' SIGINT
if
[
$(
id
-u
)
-ne
0
]
;
then
echo
-e
"plase run this script as root
\n
giving up..."
clean_up 2
elif
!
which curl jq &>/dev/null
;
then
echo
-e
"please install curl and jq
\n
giving up..."
elif
!
which jq &>/dev/null
;
then
echo
-e
"please install jq
\n
giving up..."
clean_up 2
elif
!
which curl &>/dev/null
;
then
echo
-e
"please install curl
\n
giving up..."
clean_up 2
fi
check_version
()
{
# check upstrem version
LOCAL_MD5
=
$(
md5sum
$1
|
awk
'{print $1}'
)
SCRIPT_URL
=
"https://artifactory.software.geant.org/artifactory/acme-downloader/acme-downloader.sh"
METADATA_URL
=
"https://artifactory.software.geant.org/artifactory/api/storage/acme-downloader/acme-downloader.sh"
REMOTE_MD5
=
$(
curl
-s
$METADATA_URL
| jq
-j
.checksums.md5
)
if
[[
$LOCAL_MD5
!=
$REMOTE_MD5
]]
;
then
echo
"
$1
differs from
$SCRIPT_URL
"
echo
"suggesting that you are running an older version"
echo
"in order to fetch and install the new version you can use the option: --update"
echo
""
else
if
[
-n
$CHECK
]
;
then
echo
"you are running the latest version"
fi
fi
if
[
-n
$CHECK
]
;
then
exit
0
fi
}
# lsb_release is not always installed
if
!
source
/etc/os-release &>/dev/null
;
then
echo
"no idea what to do with this OS: I was not able to access /etc/os-release"
...
...
@@ -136,6 +151,9 @@ while true; do
--update
)
UPDATE
=
'UPDATE'
;;
--check-version
)
CHECK
=
'CHECK'
;;
--
)
shift
break
...
...
@@ -146,6 +164,8 @@ done
TYPE
=
$(
echo
$TYPE
|
tr
'[:lower:]'
'[:upper:]'
)
check_version
$0
if
[
-n
$UPDATE
]
;
then
curl
$SCRIPT_URL
-o
$0
UPDATE_STATUS
=
$?
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment