Merge pull request #1686 from cincodenada/sync-s3

Adds sync_media_to_s3 command
This commit is contained in:
Mouse Reeve 2021-12-27 12:48:25 -08:00 committed by GitHub
commit a148f0e2be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

22
bw-dev
View File

@ -131,7 +131,7 @@ case "$CMD" in
makeitblack makeitblack
;; ;;
populate_streams) populate_streams)
runweb python manage.py populate_streams $@ runweb python manage.py populate_streams "$@"
;; ;;
populate_suggestions) populate_suggestions)
runweb python manage.py populate_suggestions runweb python manage.py populate_suggestions
@ -140,20 +140,33 @@ case "$CMD" in
runweb python manage.py generateimages runweb python manage.py generateimages
;; ;;
generate_preview_images) generate_preview_images)
runweb python manage.py generate_preview_images $@ runweb python manage.py generate_preview_images "$@"
;; ;;
copy_media_to_s3) copy_media_to_s3)
awscommand "bookwyrm_media_volume:/images"\ awscommand "bookwyrm_media_volume:/images"\
"s3 cp /images s3://${AWS_STORAGE_BUCKET_NAME}/images\ "s3 cp /images s3://${AWS_STORAGE_BUCKET_NAME}/images\
--endpoint-url ${AWS_S3_ENDPOINT_URL}\ --endpoint-url ${AWS_S3_ENDPOINT_URL}\
--recursive --acl public-read" --recursive --acl public-read" "$@"
;;
sync_media_to_s3)
awscommand "bookwyrm_media_volume:/images"\
"s3 sync /images s3://${AWS_STORAGE_BUCKET_NAME}/images\
--endpoint-url ${AWS_S3_ENDPOINT_URL}\
--acl public-read" "$@"
;; ;;
set_cors_to_s3) set_cors_to_s3)
set +x
config_file=$1
if [ -z "$config_file" ]; then
echo "This command requires a JSON file containing a CORS configuration as an argument"
exit 1
fi
set -x
awscommand "$(pwd):/bw"\ awscommand "$(pwd):/bw"\
"s3api put-bucket-cors\ "s3api put-bucket-cors\
--bucket ${AWS_STORAGE_BUCKET_NAME}\ --bucket ${AWS_STORAGE_BUCKET_NAME}\
--endpoint-url ${AWS_S3_ENDPOINT_URL}\ --endpoint-url ${AWS_S3_ENDPOINT_URL}\
--cors-configuration file:///bw/$@" --cors-configuration file:///bw/$config_file" "$@"
;; ;;
runweb) runweb)
runweb "$@" runweb "$@"
@ -184,6 +197,7 @@ case "$CMD" in
echo " generate_thumbnails" echo " generate_thumbnails"
echo " generate_preview_images [--all]" echo " generate_preview_images [--all]"
echo " copy_media_to_s3" echo " copy_media_to_s3"
echo " sync_media_to_s3"
echo " set_cors_to_s3 [cors file]" echo " set_cors_to_s3 [cors file]"
echo " runweb [command]" echo " runweb [command]"
;; ;;