Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unimelb-mf-clients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
resplat-mediaflux
unimelb-mf-clients
Commits
7b0c6e3d
Commit
7b0c6e3d
authored
6 years ago
by
Neil Killeen
Browse files
Options
Downloads
Patches
Plain Diff
derived from the cryoem script that downloads per namespace.
this one downloads specified assets
parent
e4ac9820
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scripts/unix/download-shell-script-url-create
+157
-0
157 additions, 0 deletions
src/main/scripts/unix/download-shell-script-url-create
with
157 additions
and
0 deletions
src/main/scripts/unix/download-shell-script-url-create
0 → 100755
+
157
−
0
View file @
7b0c6e3d
#!/bin/bash
# This script generates a URL which when consumed, will download a zip file
# The zip file holds Unix and Windows scripts for downloading the specified assets.
#
# Default values for the script arguments
EXPIRE_DAYS
=
14
OVERWRITE
=
false
VERBOSE
=
true
PROJECT
=
""
# aterm.jar download url
ATERM_URL
=
https://mediaflux.researchsoftware.unimelb.edu.au/mflux/aterm.jar
# function to print usage
usage
()
{
echo
""
echo
"Usage:"
echo
"
$(
basename
$0
)
[-h|--help] [[--project <project ID>] --expire-days <number-of-days>] [--ncsr <ncsr>] [--overwrite] [--quiet] <namespace>"
echo
""
echo
"Options:"
echo
" -h | --help prints usage."
echo
" --email <addresses> specify the email recipient of the generated url. Can be comma-separated if there are more than one."
echo
" --expire-days <number-of-days> expiry of the auth token. Defaults to
${
EXPIRE_DAYS
}
days."
echo
" --overwrite overwrite if output file exists."
echo
" --project the project ID that the assets must be drawn from."
echo
" --quiet do not print output message."
echo
""
echo
"Positional arguments:"
echo
" <id> Mediaflux asset IDs to be downloaded by the scripts. Can be multiple, but must be from the same project."
echo
""
echo
"Examples:"
echo
"
$(
basename
$0
)
--email user1@unimelb.edu.au --expire-days 10 proj-abc-1128.4.999/RAW_DATA proj-abc-1128.4.999/PROCESSED_DATA"
echo
""
}
# check java
[[
-z
$(
which java
)
]]
&&
echo
"Error: cannot find java."
1>&2
&&
exit
1
# check mflux.cfg
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
MFLUX_CFG
=
"./mflux.cfg"
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
MFLUX_CFG
=
"
${
HOME
}
/.Arcitecta/mflux.cfg"
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
MFLUX_CFG
=
"
$(
dirname
${
BASH_SOURCE
[0]
}
)
/../../config/mflux.cfg"
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
MFLUX_CFG
=
"
$(
dirname
${
BASH_SOURCE
[0]
}
)
/../../mflux.cfg"
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
MFLUX_CFG
=
"
$(
dirname
${
BASH_SOURCE
[0]
}
)
/mflux.cfg"
[[
-z
$MFLUX_CFG
||
!
-f
$MFLUX_CFG
]]
&&
echo
"Error: cannot find
${
HOME
}
/.Arcitecta/mflux.cfg."
1>&2
&&
exit
1
# check aterm.jar
[[
-z
$MFLUX_ATERM
||
!
-f
$MFLUX_ATERM
]]
&&
MFLUX_ATERM
=
"
$(
dirname
${
BASH_SOURCE
[0]
}
)
/../../lib/aterm.jar"
[[
-z
$MFLUX_ATERM
||
!
-f
$MFLUX_ATERM
]]
&&
MFLUX_ATERM
=
"
${
HOME
}
/.Arcitecta/aterm.jar"
[[
-z
$MFLUX_ATERM
||
!
-f
$MFLUX_ATERM
]]
&&
MFLUX_ATERM
=
/opt/mediaflux/bin/aterm.jar
[[
-z
$MFLUX_ATERM
||
!
-f
$MFLUX_ATERM
]]
&&
MFLUX_ATERM
=
./aterm.jar
# download aterm.jar
if
[[
-z
$MFLUX_ATERM
||
!
-f
$MFLUX_ATERM
]]
;
then
MFLUX_ATERM
=
${
HOME
}
/.Arcitecta/aterm.jar
mkdir
-p
${
HOME
}
/.Arcitecta
CURL
=
$(
which curl
)
WGET
=
$(
which wget
)
[[
-z
"
${
CURL
}
"
&&
-z
"
${
WGET
}
"
]]
&&
echo
"Error: cannot download aterm.jar. Found no curl or wget."
1>&2
&&
exit
1
if
[[
!
-z
"
${
CURL
}
"
]]
;
then
curl
-f
--create-dirs
-k
-o
"
$(
dirname
$0
)
/aterm.jar"
"
${
ATERM_URL
}
"
else
wget
--no-check-certificate
-O
"
$(
dirname
$0
)
/aterm.jar"
"
${
ATERM_URL
}
"
fi
if
[[
$?
-ne
0
]]
;
then
echo
"Error: failed to download aterm.jar"
exit
1
fi
fi
ATERM
=
"java -jar -Dmf.cfg=
$MFLUX_CFG
$MFLUX_ATERM
nogui"
SERVICE
=
unimelb.asset.download.shell.script.url.create
COMMAND
=
"
${
ATERM
}
${
SERVICE
}
"
##
## parse arguments
##
declare
-a
NAMESPACES
=()
declare
-a
EMAILS
=()
while
[[
$#
-gt
0
]]
do
key
=
"
$1
"
case
$key
in
--expire-days
)
EXPIRE_DAYS
=
"
$2
"
shift
shift
;;
--email
)
IFS
=
','
read
-r
-a
EMAILS
<<<
"
$2
"
;
unset
IFS
shift
shift
;;
--overwrite
)
OVERWRITE
=
true
shift
;;
--project
)
PROJECT
=
"
$2
"
shift
shift
;;
--quiet
)
VERBOSE
=
false
shift
;;
-h
|
--help
)
shift
usage
&&
exit
0
;;
*
)
IDS+
=(
"
$1
"
)
shift
;;
esac
done
if
[[
-z
$PROJECT
]]
;
then
echo
"Error: no project ID was specified."
1>&2
usage
exit
1
fi
if
[[
${#
IDS
[@]
}
-eq
0
]]
;
then
echo
"Error: no Mediaflux assets were specified."
1>&2
usage
exit
1
fi
COMMAND
=
"
${
COMMAND
}
:download <"
for
id
in
"
${
IDS
[@]
}
"
do
COMMAND
=
"
${
COMMAND
}
:id
${
id
}
"
done
ROLE
=
"
${
PROJECT
}
:participant-a"
ROLE_NAMESPACE
=
"
${
PROJECT
}
"
COMMAND
=
"
${
COMMAND
}
:id 2383171 :id 2383172"
COMMAND
=
"
${
COMMAND
}
:token < :role -type role
${
ROLE
}
:to now+
${
EXPIRE_DAYS
}
day > :verbose
${
VERBOSE
}
:overwrite
${
OVERWRITE
}
"
COMMAND
=
"
${
COMMAND
}
>"
COMMAND
=
"
${
COMMAND
}
:token < :perm < :resource -type role:namespace
${
ROLE_NAMESPACE
}
:access ADMINISTER > >"
if
[[
${#
EMAILS
[@]
}
-gt
0
]]
;
then
COMMAND
=
"
${
COMMAND
}
:email < "
for
email
in
"
${
EMAILS
[@]
}
"
do
COMMAND
=
"
${
COMMAND
}
:to
${
email
}
"
done
COMMAND
=
"
${
COMMAND
}
>"
fi
# execute the command to generate the url
${
COMMAND
}
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