Skip to content

Instantly share code, notes, and snippets.

@dmd
Created September 25, 2019 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmd/1277da032a57d23cad408373cf2276c4 to your computer and use it in GitHub Desktop.
Save dmd/1277da032a57d23cad408373cf2276c4 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run via sudo"
exit 1
fi
if [ "$#" -ne 3 ]; then
echo "Usage: $0 partnersid sharename mountpoint"
exit 1
fi
PARTNERSID=$1
SHARENAME=$2
MOUNTPOINT=$3
if [ ! -d "$MOUNTPOINT" ]; then
echo "$MOUNTPOINT" must be an empty directory
exit 1
fi
if ls -1qA "$MOUNTPOINT" | grep -q . ; then
echo "$MOUNTPOINT" must be an empty directory
exit 1
fi
echo -e "\nIMPORTANT NOTE: Durga mounts are NOT accessible from compute nodes (node1-5)!\n"
echo -n "Going to mount //durga/$SHARENAME on $(readlink -f $MOUNTPOINT) as $PARTNERSID. OK? (y/n): "
read -r answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
echo Please enter your PARTNERS password...
mount -t cifs -o domain=PARTNERS,username="$PARTNERSID",uid="$SUDO_USER" //durga/"$SHARENAME" "$MOUNTPOINT"
else
echo Aborted.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment