forked from kuronekomichael/aws-glacier-multipart-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloseAllConnections.sh
executable file
·46 lines (37 loc) · 1.05 KB
/
closeAllConnections.sh
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
39
40
41
42
43
44
45
46
#!/bin/bash
# This script will end all active AWS Glacier Multipart upload connections
if [ "$#" -ne 1 ]; then
echo "USAGE: $0 vault-name"
exit 1
fi
# get all active multipart upload connections
activeConn=$(aws glacier list-multipart-uploads --account-id - --vault-name $1)
i=0
while true
do
echo ""
echo "iteration $i"
# parse out the multipart upload id to remove
uploadId=$(echo $activeConn | jq '.UploadsList | .['$i'] | .MultipartUploadId' | xargs)
# ends the while loop
if [ "$uploadId" == "null" ]
then
echo "No more active connections to close"
break
else
echo "Closing connection for: $uploadId"
aws glacier abort-multipart-upload --account-id - --vault-name $1 --upload-id $uploadId
fi
# i++
i=$[$i+1]
# set a max iteration in case something breaks
if [ "$i" -gt "35" ]
then
echo "exceed iteration count"
break
fi
done
echo ""
echo "Remaining Active Connections:"
echo "(this can happen with the ID starts with -)"
aws glacier list-multipart-uploads --account-id - --vault-name $1