Created
September 25, 2019 19:14
-
-
Save dmd/1277da032a57d23cad408373cf2276c4 to your computer and use it in GitHub Desktop.
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 [[ $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