Nextjournal / Aug 13 2020
S3 / GCS access
This repo is mounted by: s3fs
apt-get update
apt-get install fuse automake build-essential make libcurl4 libcurl4-openssl-dev libxml2 libxml2-dev mime-support openssl libssl-dev libfuse-dev libtool pkg-config
# patch s3fs-fuse
cp -r /s3fs-fuse /s3fs-fuse-patched
cd /s3fs-fuse-patched
git checkout gcs-directories
./autogen.sh
./configure
make
make install
apt-get remove automake build-essential libcurl4-openssl-dev libxml2-dev libssl-dev libfuse-dev pkg-config
apt-get autoremove
rm -fr /s3fs-fuse-patched
90.3s
s3fs (Bash)
S3 type ("S3" or "GCS")
my-bucket Bucket Name ("my-bucket")
nil directory (e.g. bar)
nil secret (access_key_id:****)
true readonly? (true)
SECRET="${SECRET-_}"
MOUNT_DIR="/volumes/${MOUNT_DIR:=_}"
BUCKET="${BUCKET:=_}"
BUCKET_TYPE="${BUCKET_TYPE-_}"
READONLY="${READONLY:=_}"
case "$BUCKET" in
*.*)
bucket_options="-o use_path_request_style"
;;
*)
bucket_options=""
;;
esac
if [ -n "$SECRET" ]; then
echo "$SECRET" | tr -d '[:space:]' > ~/.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 complement_stat \
-o url=https://storage.googleapis.com
stat "$MOUNT_DIR" || :
else # S3
s3fs "$BUCKET" "$MOUNT_DIR" \
${credentials_file_option} \
${readonly_option} ${bucket_options}
fi
1.1s
Bash
s3fs