-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcheck_s3_content.sh
executable file
·48 lines (43 loc) · 1.81 KB
/
check_s3_content.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
# this scripts creates a local directory for running FMBench
# without any s3 dependency and copies all relevant files
# for public FMBench content
# RUN THIS SCRIPT AS A SANITY CHECK BEFORE EVERY NEW RELEASE
# sanity check to confirm that all config files and other files listed in manifest.txt are
# indeed present in the blogs bucket. If a file is not present in the blogs bucket then the
# CloudFormation template would error out.
BUCKET=aws-blogs-artifacts-public
CONFIGS_ONLY=configs
list_of_files_to_be_uploaded=()
for i in `cat manifest.txt | grep $CONFIGS_ONLY`
do
wget -q --spider https://${BUCKET}.s3.amazonaws.com/artifacts/ML-FMBT/$i --no-check-certificate
result=$?
if [ $result -eq 0 ]; then
#echo $i exists in the ${BUCKET}
: # noop
# check if this file is differnet from what we have in the repo
# if so then we need to flag for uploading the latest version to
# the bucket
# compare the contents of the downloaded file with the local file
TEMP_FILE=/tmp/tempfile
REMOTE_FILE=https://${BUCKET}.s3.amazonaws.com/artifacts/ML-FMBT/$i
wget -q $REMOTE_FILE --no-check-certificate -O $TEMP_FILE
LOCAL_FILE=src/fmbench/$i
if diff "$TEMP_FILE" "$LOCAL_FILE" -w> /dev/null; then
#echo "The contents of the remote file and the local file are identical."
: # noop
else
echo "contents of the $REMOTE_FILE and the local $LOCAL_FILE are different, needs to be updated manually"
list_of_files_to_be_uploaded+=($LOCAL_FILE)
fi
rm -f $TEMP_FILE
else
echo $i does not exist in the ${BUCKET}, copy it there manually
list_of_files_to_be_uploaded+=($i)
fi
done
# print a full list of all files to be uploaded
echo "here is a list of all the files to be uploaded"
for item in "${list_of_files_to_be_uploaded[@]}"; do
echo "$item"
done