#!/usr/bin/env bash # $1 Thing to mount # $2 Path to mount it to add_nfs_mount() { source="${1}"; target="${2}"; task_begin "NFS mount ${source} → ${target}"; # 1: Remove any old entries from /etc/fstab sed -i "/^$(echo "${source}" | awk '{gsub("/", "\\/", $0); print($0); }')\s/d" /etc/fstab # 2: Append the new entry echo "${source} ${target} nfs auto,nofail,noatime,_netdev,tcp,bg,timeo=50,retrans=5 0 0" >>/etc/fstab; # 3: Create the target mount point & mount mkdir -p "${target}"; mount "${target}"; task_end "$?"; } add_nfs_mount "magicbag.node.mooncarrot.space:/mnt/elfstone2/cluster" "/mnt/shared"; add_nfs_mount "magicbag.node.mooncarrot.space:/mnt/elfstone2/main /mnt/elfstone" "/mnt/elfstone"; add_nfs_mount "magicbag.node.mooncarrot.space:/mnt/elfstone2/syncthing" "/mnt/elessar-syncthing";