-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws-getLatestUserSubmission
executable file
·62 lines (54 loc) · 1.65 KB
/
aws-getLatestUserSubmission
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
SEASON="season-$(date +%Y-%m)"
DATASEASON='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetLatestUserSubmission"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"LeaderboardArn\":\"'
function usage {
echo "Usage: `basename $0` -s [season-yyyy-mm|community race name] -c"
echo "-s if it is not used, the race name is set to season-<current year>-<current-month>"
echo "-c is optional for community race"
}
c_flag=0
while getopts "cs:" opt; do
case "$opt" in
c)
c_flag=1
;;
s)
SEASONX=(${OPTARG//-/ })
if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null
then
SEASON="season-$OPTARG"
else
SEASON="$OPTARG"
fi
;;
\?)
usage
exit
;;
esac
done
if [ $c_flag -eq 1 ]; then
LEADERBOARDS=$(./aws-listSubscribedPrivateLeaderboards)
echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null
if [ $? == 0 ]; then
echo $LEADERBOARDS
exit 1
fi
ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g')
else
LEADERBOARDS=$(./aws-listLeaderboards)
echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null
if [ $? == 0 ]; then
echo $LEADERBOARDS
exit 1
fi
ARN=$(echo $LEADERBOARDS | jq '.Leaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g')
fi
if [ -z "$ARN" ]; then
echo '{ "error": [ "'$SEASON' does not exist" ] }'
exit 1
fi
DATASEASON="$DATASEASON$ARN"
DATA=$DATASEASON'\"}","operation":"getLatestUserSubmission"}'
export DATA
./aws-execCurl | jq '.'