bharendt / Nov 15 2018
S3 / GCS access
S3 / GCS access
apt-get update apt-get install s3fs apt-get clean
S3 type ("S3" or "GCS")
bucket ("my-bucket")
directory (e.g. bar)
secret (access_key_id:****)
true readonly? (true)
0.9s
SECRET="${SECRET-NJ__REFc07207d2_a217_481f_8642_488e3561e68a_}" MOUNT_DIR="/volumes/${MOUNT_DIR:=NJ__REFc6ab5ac9_9699_47fc_832e_cb897d1048c5_}" BUCKET="${BUCKET:=NJ__REF22249ad5_a22d_48f4_91a1_4a568b9055fe_}" BUCKET_TYPE="${BUCKET_TYPE-NJ__REF0708a01e_9d4b_4dde_8ac0_e91907f9d461_}" READONLY="${READONLY:=NJ__REF22249ad5_a22d_48f4_91a1_4a568b9055fe_}" if [ -n "$SECRET" ]; then echo "$SECRET" > ~/.passwd-s3fs chmod 600 ~/.passwd-s3fs credentials_file_option=" -o passwd_file=/root/.passwd-s3fs" else credentials_file_option=" -o public_bucket=1" fi if [ "$READONLY" = "false" ]; then readonly_option="" else readonly_option=" -oro" fi if cat /proc/mounts | grep "${MOUNT_DIR} " >/dev/null 2>/dev/null; then umount -vf "$MOUNT_DIR" fi mkdir -p "$MOUNT_DIR" if [ "$BUCKET_TYPE" = "GCS" ]; then s3fs "$BUCKET" "$MOUNT_DIR" \ ${credentials_file_option} \ ${readonly_option} \ -o sigv2 \ -o nomultipart \ -o allow_other \ -o url=https://storage.googleapis.com stat "$MOUNT_DIR" || : else # S3 s3fs "$BUCKET" "$MOUNT_DIR" \ ${credentials_file_option} \ ${readonly_option} fi