Skip to content

Instantly share code, notes, and snippets.

@junichim
Created November 10, 2021 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichim/4c24be7667a3c62b410ab744f0362544 to your computer and use it in GitHub Desktop.
Save junichim/4c24be7667a3c62b410ab744f0362544 to your computer and use it in GitHub Desktop.
避難所データのアップロードスクリプト
#!/bin/bash
#
# upload shelter file in public folder to S3 bucket.
#
# 2021/11/9, Junichi MORI
BUCKET_BASE="s3://バケット名"
function usage {
echo "Usage: uploadShelter [-d] [-h] aws_profile_name"
echo " -d: drun run"
echo " -h: show this message"
echo " aws_profile_name"
}
script_dir=$(cd $(dirname $0); pwd)
SHELTER_FILE=$(dirname $script_dir)/iseshi_shelters.csv
TS_FILE=$(dirname $script_dir)/shelter_timestamp
# processing options
DRYRUN=
while getopts dh ARG
do
case $ARG in
"d") DRYRUN='--dryrun' ;;
"h" | * ) usage
exit 1 ;;
esac
done
shift $((OPTIND -1))
if [ $# -ne 1 ]
then
usage
exit 1
fi
AWS_PROFILE=$1
BUCKET=${BUCKET_BASE}"/v1/"
# upload shelter file to s3 bucket
if [ -f ${SHELTER_FILE} ]
then
echo aws --profile $AWS_PROFILE s3 cp ${SHELTER_FILE} ${BUCKET} ${DRYRUN}
aws --profile $AWS_PROFILE s3 cp ${SHELTER_FILE} ${BUCKET} ${DRYRUN}
else
echo ${SHELTER_FILE} not found
fi
if [ -f ${TS_FILE} ]
then
echo aws --profile $AWS_PROFILE s3 cp ${TS_FILE} ${BUCKET} ${DRYRUN}
aws --profile $AWS_PROFILE s3 cp ${TS_FILE} ${BUCKET} ${DRYRUN}
else
echo ${TS_FILE} not found
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment