Nextjournal / Aug 08 2019

Google Cloud Filestore Env

Environment used to mount Google Cloud Filestores as NAS.

apt-get -y update
apt-get install nfs-common telnet
cat /proc/filesystems | awk '{print $NF}' | sed '/^$/d' | sort

Bindings:

directory

fileshare

fileshare-ip

readonly?

set -x
MOUNT_DIR="/volumes/${MOUNT_DIR:=NJ__REF_}"
FILESHARE="${FILESHARE:=NJ__REF_}"
FILESHARE_IP="${FILESHARE_IP:=NJ__REF_}"
READONLY="${READONLY:=NJ__REF_}"
exec 2>&1
export

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"
# fail after about 18 seconds when mounting, default is 6 minutes
mount -v -t nfs $readonly_option \
      -o timeo=30,retry=0,retrans=3 \
      -o nfsvers=3 -o nolock \
      "${FILESHARE_IP}:/${FILESHARE}" "$MOUNT_DIR"