Writing a bash script to push local files to Amazon EC2 and S3 - needs proper owner/permissions -


i have php project on local machine, following folder structure

  assets/   |- css/   |- ...   |- js/   |- ...   dynamic/   |- scripts/ *contains bunch of .php files 

the plan push assets/ directory amazon s3 (for use cloudfront cdn) using s3cmd , push dynamic/ files amazon ec2 instance (web-server) directly.

the base script i'm using below:

[push.sh]

#!/bin/bash  # source our program variables . ./_global.sh  # setup build directory echo "======== preparing build directory ==============" node build/r.js -o build/build.js  # start rsync push dynamic files echo "==== syncing dynamic files ec2 instance ====" rsync -rvzh --progress --delete --exclude-from "${build_dir}exclude-list.txt" \     -e "ssh -i ${build_dir}mykey.pem" \     $www_built_dir ubuntu@$server_ip:$server_dir  # push static assets s3 echo "========== pushing static assets s3  =========" s3cmd sync --delete-removed --exclude-from "${build_dir}exclude-list.txt" \     ${www_dir}${assets} s3://mybucketname/${assets}  echo "all done :)" 

everything works perfectly, except permissions on files pushed ec2 web server set user configured in ssh command (ubuntu). how can set use :www-data instead?

after done, can put in script execute commands remotely (e.g. chown, chmod , like),

ssh -l root -i ${build_dir}mykey.pem" $server_ip "chown whateveruser:whatevergroup $server_dir" 

syntax:

ssh -l root -i key $server_ip "your command" 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -