Skip to content

Instantly share code, notes, and snippets.

@jmfernandez
Created January 25, 2019 14:51
Show Gist options
  • Save jmfernandez/8e5c02f0e33ed83ddea76d3c3d8e8d24 to your computer and use it in GitHub Desktop.
Save jmfernandez/8e5c02f0e33ed83ddea76d3c3d8e8d24 to your computer and use it in GitHub Desktop.
Bash wrapper which runs a command line only when a directory is in a NFS volume
#!/bin/bash
if [ $# -ge 1 ] ; then
folder="$1"
shift
if [ -d "$folder" ] ; then
if df --output=fstype "$folder" | grep -qF nfs ; then
# Launch the guarded program here
eval "$@"
else
echo "Target folder is not mounted. Stopping script execution" 1>&2
exit 2
fi
else
echo "Target folder does not exist. Stopping script execution" 1>&2
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment