-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathzenodo_add_to_communities.sh
More file actions
executable file
·38 lines (32 loc) · 1 KB
/
zenodo_add_to_communities.sh
File metadata and controls
executable file
·38 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Add submitted deposit to communities
#
# usage: ./zenodo_remove_from_communities.sh [deposit id] [metadata filename] [--verbose|-v]
#
# with metadata containing the uuids of the communities that you'd like the deposit to be added to
#
# {"communities":[{"id":"e61e4c2d-471e-49ef-9e56-794390b01c59"}]}
set -ex
VERBOSE=0
if [ "$3" == "--verbose" ] || [ "$3" == "-v" ]; then
VERBOSE=1
fi
DEPOSIT="$1"
FILEPATH="$2"
FILENAME=$(echo $FILEPATH | sed 's+.*/++g')
FILENAME=${FILENAME// /%20}
ZENODO_ENDPOINT=${ZENODO_ENDPOINT:-https://zenodo.org}
DEPOSITION_ENDPOINT="${ZENODO_ENDPOINT}/api/records/${DEPOSIT}/communities"
if [ "$VERBOSE" -eq 1 ]; then
echo "Deposition ID: ${DEPOSITION}"
echo "File path: ${FILEPATH}"
echo "File name: ${FILENAME}"
echo "Requesting to update deposition..."
fi
curl --progress-bar \
--retry 5 \
--retry-delay 5 \
-H "Content-Type: application/json" \
-X POST\
--data "@${FILEPATH}" \
"${DEPOSITION_ENDPOINT}?access_token=${ZENODO_TOKEN}"