forked from unfoldingWord/door43.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3_push.sh
executable file
·66 lines (59 loc) · 1.45 KB
/
s3_push.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
#!/usr/bin/env bash
# -*- coding: utf8 -*-
#
# Copyright (c) 2016-2017 unfoldingWord
# http://creativecommons.org/licenses/MIT/
# See LICENSE file for details.
#
# Contributors:
# Jesse Griffin <[email protected]>
SOURCE="_site"
EXCLUDES="s3_excludes"
PROGNAME="${0##*/}"
help() {
echo "Syncs _site to specified S3 bucket"
echo
echo "Usage:"
echo " $PROGNAME -b <s3 bucket>"
echo " $PROGNAME --help"
echo
echo "Example:"
echo " $PROGNAME -b \"s3://dev-door43.org\""
exit 1
}
if [ $# -lt 1 ]; then
help
fi
while test -n "$1"; do
case "$1" in
--help|-h)
help
;;
--bucket|-b)
BKT="$2"
shift
;;
*)
echo "Unknown argument: $1"
help
;;
esac
shift
done
[ -z "$BKT" ] && help
openssl aes-256-cbc -K $encrypted_e2db0eb08244_key -iv $encrypted_e2db0eb08244_iv -in secrets.tar.enc -out secrets.tar -d
tar xvf secrets.tar
for x in `ls "$SOURCE"`; do
[ "$x" == "assets" ] && continue
echo "Syncing $x"
[ -d "$SOURCE/$x" ] && s3cmd -c s3cfg-prod sync -M -F \
--no-mime-magic \
--exclude-from "$EXCLUDES" \
--add-header="Cache-Control:max-age=600" \
"$SOURCE/$x/" "$BKT/$x/"
[ -f "$SOURCE/$x" ] && s3cmd -c s3cfg-prod put -M -F \
--no-mime-magic \
--add-header="Cache-Control:max-age=600" \
"$SOURCE/$x" "$BKT/"
done
echo "Done!"