-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathresource-mount.sh
More file actions
51 lines (41 loc) · 1.53 KB
/
resource-mount.sh
File metadata and controls
51 lines (41 loc) · 1.53 KB
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
#!/bin/bash
# resource-mount.sh
#
# Installs gcsfuse if it is not already installed and mount resources.
#
# Both apt and install-from-source steps are based on gcloud docs here:
# https://cloud.google.com/storage/docs/gcsfuse-install
#
# Note that this script is intended to be sourced from the "post-startup.sh" script
# and is dependent on some functions and variables already being set:
#
# - emit (function)
# - Workbench CLI is installed
if ! which gcsfuse >/dev/null 2>&1; then
if type apk > /dev/null 2>&1; then
emit "Installing gcsfuse from source..."
apk add --no-cache fuse git go
export GOROOT=/usr/lib/go
export GOPATH=/go
mkdir -p ${GOPATH}/src ${GOPATH}/bin
go install github.com/googlecloudplatform/gcsfuse/v2@master
cp ${GOPATH}/bin/gcsfuse /usr/bin/gcsfuse
elif type apt-get > /dev/null 2>&1; then
emit "Installing gcsfuse from apt package..."
# install packages needed to install gcsfuse
apt-get install -y \
fuse \
lsb-release
GCSFUSE_REPO="gcsfuse-$(lsb_release -c -s)"
readonly GCSFUSE_REPO
echo "deb https://packages.cloud.google.com/apt ${GCSFUSE_REPO} main" > /etc/apt/sources.list.d/gcsfuse.list
curl "https://packages.cloud.google.com/apt/doc/apt-key.gpg" | apt-key add -
apt-get update \
&& apt-get install -y gcsfuse
fi
else
emit "gcsfuse already installed. Skipping installation."
fi
if [[ "${LOG_IN}" == "true" ]]; then
${RUN_AS_LOGIN_USER} "'${WORKBENCH_INSTALL_PATH}' resource mount --allow-other || echo 'Resource mounting failed.'"
fi