Skip to content

Instantly share code, notes, and snippets.

@dcai
Last active August 29, 2015 14:13
Show Gist options
  • Save dcai/ac1c0f8c9645e3413ec5 to your computer and use it in GitHub Desktop.
Save dcai/ac1c0f8c9645e3413ec5 to your computer and use it in GitHub Desktop.
Mount samba
#!/bin/sh
# smbclient -L 10.0.1.1
mounttc ()
{
sudo echo -n;
if [[ -z $1 ]]; then
SERVER="10.0.1.1";
else
SERVER="$1";
fi;
if [[ -z $2 ]]; then
SHARENAME="Data";
else
SHARENAME="$2";
fi;
if [[ -z $3 ]]; then
LOCALPATH="$HOME/smb/$3";
else
LOCALPATH="$3";
fi;
if [ ! -d "$LOCALPATH" ]; then
mkdir -p "$LOCALPATH";
fi;
echo "Mounting //${SERVER}/${SHARENAME} to ${LOCALPATH}";
OPT="username=dcai,password=68b329d,rw,noperm,uid=dcai,file_mode=0777,dir_mode=0777,sec=ntlm";
sudo mount -t cifs "//${SERVER}/${SHARENAME}" "${LOCALPATH}" -o "$OPT" > /dev/null 2> /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment