From 8eb340945bd29ff55089912e2ce96e614d490214 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Thu, 16 Dec 2021 08:47:03 +0000 Subject: [PATCH 1/3] Add sync_media_to_s3 command This is useful if the copy gets aborted, or to sync over remnants generated between the copy and the switchover to S3 --- bw-dev | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bw-dev b/bw-dev index cfe8747f..0a06b5ed 100755 --- a/bw-dev +++ b/bw-dev @@ -146,7 +146,13 @@ case "$CMD" in awscommand "bookwyrm_media_volume:/images"\ "s3 cp /images s3://${AWS_STORAGE_BUCKET_NAME}/images\ --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) awscommand "$(pwd):/bw"\ @@ -184,6 +190,7 @@ case "$CMD" in echo " generate_thumbnails" echo " generate_preview_images [--all]" echo " copy_media_to_s3" + echo " sync_media_to_s3" echo " set_cors_to_s3 [cors file]" echo " runweb [command]" ;; From 37a7899f6f72f8b2e77a790ef7ff1222f302ac58 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Thu, 16 Dec 2021 08:48:34 +0000 Subject: [PATCH 2/3] Consistently quote $@, check for argument Also add $@ to a couple commands, and add a check for the argument to the CORS command since it's required --- bw-dev | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bw-dev b/bw-dev index 0a06b5ed..97a38834 100755 --- a/bw-dev +++ b/bw-dev @@ -131,7 +131,7 @@ case "$CMD" in makeitblack ;; populate_streams) - runweb python manage.py populate_streams $@ + runweb python manage.py populate_streams "$@" ;; populate_suggestions) runweb python manage.py populate_suggestions @@ -140,7 +140,7 @@ case "$CMD" in runweb python manage.py generateimages ;; generate_preview_images) - runweb python manage.py generate_preview_images $@ + runweb python manage.py generate_preview_images "$@" ;; copy_media_to_s3) awscommand "bookwyrm_media_volume:/images"\ @@ -155,11 +155,18 @@ case "$CMD" in --acl public-read" "$@" ;; 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"\ "s3api put-bucket-cors\ --bucket ${AWS_STORAGE_BUCKET_NAME}\ --endpoint-url ${AWS_S3_ENDPOINT_URL}\ - --cors-configuration file:///bw/$@" + --cors-configuration file:///bw/$config_file" "$@" ;; runweb) runweb "$@" From faffbdce21ae143205a7e8a40f1686d9cb6ed263 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Thu, 16 Dec 2021 23:44:47 -0800 Subject: [PATCH 3/3] Fix spacing --- bw-dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bw-dev b/bw-dev index 97a38834..da36ae05 100755 --- a/bw-dev +++ b/bw-dev @@ -155,13 +155,13 @@ case "$CMD" in --acl public-read" "$@" ;; set_cors_to_s3) - set +x + 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 + set -x awscommand "$(pwd):/bw"\ "s3api put-bucket-cors\ --bucket ${AWS_STORAGE_BUCKET_NAME}\