Created
January 25, 2019 14:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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