forked from mozilla/autophone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ap-getlogs
executable file
·65 lines (57 loc) · 1.4 KB
/
ap-getlogs
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
63
64
65
#!/bin/bash
options="s:p:h"
function usage()
{
cat<<EOF
usage: $(basename $0) [-h] [-t [production|staging]] [-p prefix]
optional arguments:
-h
show this help message
-s [production|staging]
Download logs from either production or staging AWS. (default: production)
-p prefix
Path prefix used to select logs to download.
EOF
exit 0
}
server=https://autophone.s3.amazonaws.com
credentials=production-autophone-1-credentials.ini
let nshift=0
while getopts $options optname; do
case $optname in
h) usage;;
s) if [[ "$OPTARG" == "staging" ]]; then
server=https://autophone-dev.s3.amazonaws.com
credentials=developer-credentials.ini
fi
let nshift=nshift+2
;;
p) prefix="$OPTARG"
let nshift=nshift+2
;;
esac
done
shift $nshift
if [[ -z "$prefix" ]]; then
usage
fi
if echo $VIRTUAL_ENV | grep -q autophone; then
true
else
. $ACTIVATE_AUTOPHONE
fi
cd $AUTOPHONE_PATH
python s3.py --config $credentials --prefix "$prefix" --ls "$prefix" | while read filepath; do
if [[ -e $filepath ]]; then
true
continue
else
echo filepath=$filepath
fi
dirpath=$(dirname $filepath)
echo dirpath=$dirpath
url="$server/$filepath"
echo url=$url
curl --create-dirs -o $filepath.gz $url
gunzip $filepath.gz
done