-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·63 lines (52 loc) · 1.26 KB
/
entrypoint.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
#!/bin/sh
set -e
if [ -z "$COMMAND" ]; then
echo "You must specify a command to execute. Quitting."
exit 1
fi
if [ -z "$S3_BUCKET" ]; then
echo "S3_BUCKET is not set. Quitting."
exit 1
fi
if [ -z "$S3_ACCESS_KEY_ID" ]; then
echo "S3_ACCESS_KEY_ID is not set. Quitting."
exit 1
fi
if [ -z "$S3_SECRET_ACCESS_KEY" ]; then
echo "S3_SECRET_ACCESS_KEY is not set. Quitting."
exit 1
fi
# Default to us-east-1 if AWS_REGION not set.
if [ -z "$S3_REGION" ]; then
S3_REGION="us-east-1"
fi
# Override default AWS endpoint if user sets S3_ENDPOINT
if [ -n "$S3_ENDPOINT" ]; then
ENDPOINT_APPEND="--endpoint-url ${S3_ENDPOINT}"
fi
S3_PROFILE="--profile action-s3-utility"
# Create a dedicated profile for this action
aws configure --profile action-s3-utility <<-EOF >/dev/null 2>&1
${S3_ACCESS_KEY_ID}
${S3_SECRET_ACCESS_KEY}
${S3_REGION}
text
EOF
if [[ "$COMMAND" == "ls" ]]; then
. /commands/ls.sh
elif [[ "$COMMAND" == "sync" ]]; then
. /commands/sync.sh
elif [[ "$COMMAND" == "exists" ]]; then
. /commands/exists.sh
elif [[ "$COMMAND" == "rm" ]]; then
. /commands/rm.sh
elif [[ "$COMMAND" == "cp" ]]; then
. /commands/cp.sh
fi
# Clear out credentials after we're done.
aws configure --profile action-s3-utility <<-EOF >/dev/null 2>&1
null
null
null
text
EOF