-
Notifications
You must be signed in to change notification settings - Fork 244
/
setup_gcsfuse.sh
59 lines (49 loc) · 1.9 KB
/
setup_gcsfuse.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# bash setup_gcsfuse.sh DATASET_GCS_BUCKET=maxtext-dataset MOUNT_PATH=dataset
set -e
# Set environment variables
for ARGUMENT in "$@"; do
IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
export "$KEY"="$VALUE"
echo "$KEY"="$VALUE"
done
if [[ -z ${DATASET_GCS_BUCKET} || -z ${MOUNT_PATH} ]]; then
echo "Please set arguments: DATASET_GCS_BUCKET and MOUNT_PATH"
exit 1
fi
if [[ $GCS_BUCKET == gs:https://* ]] ; then
echo "Remove gs:https:// from GCS bucket name"
exit 1
fi
if ! command -v sudo &> /dev/null ; then
apt install sudo
fi
if ! command -v gcsfuse &> /dev/null ; then
sudo apt-get update -y && \
sudo apt-get install -y lsb-release && \
sudo apt-get install -y gnupg && \
sudo apt-get install -y curl
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb https://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update -y && sudo apt-get -y install gcsfuse
sudo rm -rf /var/lib/apt/lists/*
fi
mkdir -p $MOUNT_PATH
gcsfuse --implicit-dirs --http-client-timeout=5s --max-conns-per-host=2000 \
--debug_fuse_errors --debug_fuse --debug_gcs --debug_invariants --debug_mutex \
--log-file=$HOME/gcsfuse.json "$DATASET_GCS_BUCKET" "$MOUNT_PATH"