-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbucket.sh
37 lines (29 loc) · 1.59 KB
/
bucket.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
#!/bin/bash
VAL_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$VAL_DIR" ]]; then
VAL_DIR="$PWD";
fi
aws s3api help > /dev/null 2>&1
if [ ! $? == 0 ]; then
echo "Installing aws cli ..."
wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip > /dev/null 2>&1
echo "A" | unzip awscli-bundle.zip > /dev/null 2>&1
echo "Configuring aws cli ..."
python3 ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws > /dev/null 2>&1
python3 ./awscli-bundle/install -b ~/bin/aws > /dev/null 2>&1
python3 ./awscli-bundle/install -h > /dev/null 2>&1
fi
base_dir=$(awk ''/^base_dir:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
storage_type=$(awk ''/^storage_type:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
base_dir=$(awk ''/^base_dir:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
aws_access_key=$(awk ''/^s3_access_key:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
aws_secret_key=$(awk ''/^s3_secret_key:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
aws_default_region=$(awk ''/^aws_default_region:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
remote_bucket=$(awk ''/^s3_output_bucket:' /{ if ($2 !~ /#.*/) {print $2}}' ~/cQube_Base/migrate_config.yml)
bucket=$(cat $base_dir/cqube/.cqube_config | grep CQUBE_S3_OUTPUT )
output_bucket=$(cut -d "=" -f2 <<< "$bucket")
#echo $output_bucket
#export AWS_DEFAULT_REGION='$aws_default_region'
export AWS_ACCESS_KEY_ID=$aws_access_key
export AWS_SECRET_ACCESS_KEY=$aws_secret_key
rbucket=$(aws s3 sync s3://$output_bucket s3://$remote_bucket)