-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsync.sh
executable file
·67 lines (60 loc) · 1.92 KB
/
sync.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -e
set -o pipefail
url_encode() {
local encoded=""
local char=""
for (( i = 0; i < ${#1}; i++ )); do
char="${1:$i:1}"
if [[ "$char" =~ [a-zA-Z0-9.~_-] ]]; then
encoded+="$char"
else
printf -v hex '%02X' "'$char"
encoded+="%$hex"
fi
done
echo "$encoded"
}
if [ -n "${AWS_SECRET_ACCESS_KEY}" ] && [ -n "${AWS_ACCESS_KEY_ID}" ] && [ -n "${FO_REGION}" ]; then
if [ -n "${S3_STATS_URI}" ]; then
for subdir in /updater/stats/*; do
if [[ -d "$subdir" ]]; then
for file in "$subdir"/*.json; do
[ -e "$file" ] || continue
filename=$(basename "$file")
subdir_name=$(basename "$subdir")
if /usr/local/bin/aws s3 cp "$file" "$S3_STATS_URI/$FO_REGION/$subdir_name/$filename"; then
rm $file
# Notify haze stats
if [ -n "${FO_STATS_FILES_ADDRESS}" ]; then
curl "$FO_STATS_FILES_ADDRESS/notify/$FO_REGION/$subdir_name/$(url_encode "$filename")"
echo "$FO_STATS_FILES_ADDRESS/notify/$FO_REGION/$subdir_name/$(url_encode "$filename")" notification sent
fi
else
echo "Error syncing to $S3_STATS_URI/$FO_REGION/$subdir_name/$filename"
fi
done
fi
done
fi
if [ -n "${S3_DEMO_URI}" ]; then
/usr/local/bin/aws s3 sync /updater/demos/ "${S3_DEMO_URI}/${FO_REGION}/" \
&& find /updater/demos/ \( -name "*.mvd" -o -name "*.gz" \) -type f -mtime +6 -delete 2>/dev/null
fi
fi
# sync down qwprogs
/usr/local/bin/aws s3 sync \
--no-sign-request \
--exact-timestamps \
--cli-read-timeout 600 \
--cli-connect-timeout 600 \
s3://fortressone-dats \
/updater/dats/
# sync down maps
/usr/local/bin/aws s3 sync \
--size-only \
--no-sign-request \
--cli-read-timeout 600 \
--cli-connect-timeout 600 \
s3://fortressone-package \
/updater/map-repo/fortress/maps/