-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·69 lines (58 loc) · 1.16 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
64
65
66
67
68
69
#!/bin/bash
set -x
usage() {
echo "Usage: docker run spotx/hadoop-distcp -a AccessKey -s SecretKey -b S3BucketWithPath"
exit 1
}
accessKey=""
secretKey=""
s3Bucket=""
# Call getopt to validate the provided input.
options=$(getopt -o ha:b:s: -- "$@")
[ $? -eq 0 ] || {
echo "Incorrect options provided"
exit 1
}
eval set -- "$options"
while true; do
case "$1" in
-a)
shift;
accessKey="$1"
;;
-b)
shift;
s3Bucket="$1"
;;
-h)
usage
;;
-s)
shift;
secretKey="$1"
;;
--)
shift
break
;;
esac
shift
done
if [ "${accessKey}" = "" ] || [ "${secretKey}" = "" ] || [ "${s3Bucket}" = "" ]
then
usage
fi
now="$(date -uIs)"
echo "Test date: "$now > testfile
# all -D params must be first, then pass the distcp specific params (like -overwrite)
hadoop distcp \
-Dfs.s3a.acl.default=BucketOwnerFullControl \
-Dfs.s3a.access.key="${accessKey}" -Dfs.s3a.secret.key="${secretKey}" \
-overwrite \
testfile s3a://${s3Bucket}
if [ $? -eq 0 ]
then
echo "[SUCCESS] Test completed successfully."
else
echo "[ERROR] Test failed."
fi