Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment Client
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
IML Open Source
Imldeployment Client
Commits
a136a4e4
Commit
a136a4e4
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add nanoseconds in hashed base data; add url param -h and -v
parent
afd5f537
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/getfile.sh
+35
-7
35 additions, 7 deletions
bin/getfile.sh
with
35 additions
and
7 deletions
bin/getfile.sh
+
35
−
7
View file @
a136a4e4
...
@@ -3,16 +3,23 @@
...
@@ -3,16 +3,23 @@
#
#
# API CLIENT :: GET A CI FILE FROM PACKAGE SERVER
# API CLIENT :: GET A CI FILE FROM PACKAGE SERVER
#
#
# Source: https://git-repo.iml.unibe.ch/iml-open-source/imldeployment-client/
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2021-03-31 v1.0 <axel.hahn@iml.unibe.ch> init
# 2021-03-31 v1.0 <axel.hahn@iml.unibe.ch> init
# 2021-04-13 v1.1 <axel.hahn@iml.unibe.ch> add support for custom config
# 2021-04-13 v1.1 <axel.hahn@iml.unibe.ch> add support for custom config
# 2021-04-15 v1.2 <axel.hahn@iml.unibe.ch> added debugging of curl request
# 2021-04-15 v1.2 <axel.hahn@iml.unibe.ch> added debugging of curl request
# 2021-10-14 v1.3 <axel.hahn@iml.unibe.ch> add nanoseconds in hashed base data
# ======================================================================
# ======================================================================
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# CONFIG
# CONFIG
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
version
=
"v1.3"
about
=
"CI PACKAGE GETTER
$version
;
(c) 2021 Institute for Medical Education (IML); University of Bern;
GNU GPL 3.0"
line
=
"----------------------------------------------------------------------"
line
=
"----------------------------------------------------------------------"
bDebug
=
0
bDebug
=
0
customconfig
=
customconfig
=
...
@@ -25,8 +32,9 @@ customconfig=
...
@@ -25,8 +32,9 @@ customconfig=
function
showhelp
(){
function
showhelp
(){
self
=
$(
basename
$0
)
self
=
$(
basename
$0
)
echo
"
echo
"
$line
CIPGK GETTER
$about
$line
Get packages from a software sattelite of IML ci server.
Get packages from a software sattelite of IML ci server.
...
@@ -36,6 +44,9 @@ SYNTAX:
...
@@ -36,6 +44,9 @@ SYNTAX:
OPTIONS:
OPTIONS:
-h Show this help
-v Show version
-c CFGFILE load custom config file after defaults in
$self
.cfg
-c CFGFILE load custom config file after defaults in
$self
.cfg
-d enable debug infos
-d enable debug infos
-e PHASE phase; overrides env variable IMLCI_PHASE
-e PHASE phase; overrides env variable IMLCI_PHASE
...
@@ -45,7 +56,7 @@ OPTIONS:
...
@@ -45,7 +56,7 @@ OPTIONS:
-p PROJECT ci project id; overrides env variable IMLCI_PROJECT
-p PROJECT ci project id; overrides env variable IMLCI_PROJECT
-s SECRET override secret in IMLCI_PKG_SECRET
-s SECRET override secret in IMLCI_PKG_SECRET
-u URL URL of iml ci server without trailing /; overrides env variable IMLCI_URL
-u URL URL of iml ci server without trailing /; overrides env variable IMLCI_URL
VALUES:
VALUES:
CFGFILE custom config file. It is useful to handle files of different
CFGFILE custom config file. It is useful to handle files of different
...
@@ -92,7 +103,15 @@ EXAMPLES:
...
@@ -92,7 +103,15 @@ EXAMPLES:
"
"
}
}
# make an http request to fetch the software
#
# param string method; should be GET
# param string request url (without protocol and server)
# param string optional: filename for output data
# param string optional: secret; default: it will be generated
#
# global int bDebug (0|1)
# global string line string for a line with dashes
function
makeRequest
(){
function
makeRequest
(){
local
apiMethod
=
$1
local
apiMethod
=
$1
...
@@ -113,7 +132,7 @@ function makeRequest(){
...
@@ -113,7 +132,7 @@ function makeRequest(){
# --- date in http format
# --- date in http format
LANG
=
en_EN
LANG
=
en_EN
# export TZ=GMT
# export TZ=GMT
apiTS
=
`
date
"+%a, %d %b %Y %H:%M:%S %Z"
`
apiTS
=
`
date
"+%a, %d %b %Y %H:%M:%S
.%N
%Z"
`
# --- generate data to hash: method + uri + timestamp; delimited with line break
# --- generate data to hash: method + uri + timestamp; delimited with line break
...
@@ -121,6 +140,11 @@ data="${apiMethod}
...
@@ -121,6 +140,11 @@ data="${apiMethod}
${
apiRequest
}
${
apiRequest
}
${
apiTS
}
${
apiTS
}
"
"
# these ase non critical data ... it does not show the ${secret}
if
[
"
$bDebug
"
=
"1"
]
;
then
echo
"RAW data for hashed secret:"
echo
"
$data
"
fi
# generate hash - split in 2 commands (piping "cut" sends additional line break)
# generate hash - split in 2 commands (piping "cut" sends additional line break)
myHash
=
`
echo
-n
"
$data
"
| openssl sha1
-hmac
"
${
secret
}
"
|
cut
-f
2
-d
" "
`
myHash
=
`
echo
-n
"
$data
"
| openssl sha1
-hmac
"
${
secret
}
"
|
cut
-f
2
-d
" "
`
...
@@ -134,7 +158,7 @@ ${apiTS}
...
@@ -134,7 +158,7 @@ ${apiTS}
curl
\
curl
\
-H
"Accept: application/json"
-H
"Content-Type: application/json"
\
-H
"Accept: application/json"
-H
"Content-Type: application/json"
\
-H
"Date:
${
apiTS
}
"
\
-H
"Date:
${
apiTS
}
"
\
-H
"Authorization:
demo-
bash-client:
${
myHash
}
"
\
-H
"Authorization: bash-client:
${
myHash
}
"
\
-X
$apiMethod
\
-X
$apiMethod
\
-o
"
${
tmpdownloadfile
}
"
\
-o
"
${
tmpdownloadfile
}
"
\
$moreheaders
\
$moreheaders
\
...
@@ -186,12 +210,15 @@ if [ $# -lt 1 ]; then
...
@@ -186,12 +210,15 @@ if [ $# -lt 1 ]; then
fi
fi
while
getopts
"c:de:f:l:o:p:s:u:"
option
;
do
while
getopts
"c:de:f:
h
l:o:p:s:u:
v
"
option
;
do
case
${
option
}
in
case
${
option
}
in
c
)
customconfig
=
"
$OPTARG
"
;;
c
)
customconfig
=
"
$OPTARG
"
;;
d
)
bDebug
=
1
;;
d
)
bDebug
=
1
;;
e
)
export
IMLCI_PHASE
=
$OPTARG
;;
e
)
export
IMLCI_PHASE
=
$OPTARG
;;
f
)
export
IMLCI_FILE
=
$OPTARG
;;
f
)
export
IMLCI_FILE
=
$OPTARG
;;
h
)
showhelp
exit
0
;;
l
)
case
$OPTARG
in
l
)
case
$OPTARG
in
phases
)
phases
)
IMLCI_PHASE
=
''
IMLCI_PHASE
=
''
...
@@ -216,6 +243,7 @@ while getopts "c:de:f:l:o:p:s:u:" option; do
...
@@ -216,6 +243,7 @@ while getopts "c:de:f:l:o:p:s:u:" option; do
p
)
export
IMLCI_PROJECT
=
$OPTARG
;;
p
)
export
IMLCI_PROJECT
=
$OPTARG
;;
s
)
export
IMLCI_PKG_SECRET
=
$OPTARG
;;
s
)
export
IMLCI_PKG_SECRET
=
$OPTARG
;;
u
)
export
IMLCI_URL
=
$OPTARG
;;
u
)
export
IMLCI_URL
=
$OPTARG
;;
v
)
echo
$about
;
exit
0
;;
*
)
*
)
echo
ERROR: invalid option
[
${
option
}
]
echo
ERROR: invalid option
[
${
option
}
]
echo
echo
...
...
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