Skip to content

Instantly share code, notes, and snippets.

@andy722
Created February 7, 2011 22:02
Show Gist options
  • Save andy722/815330 to your computer and use it in GitHub Desktop.
Save andy722/815330 to your computer and use it in GitHub Desktop.
Mount all shares of SMB server
#!/bin/bash
mnt_dir="/mnt"
server=$1
temp="/tmp/mnts_$$"
die() {
echo "Some error occured"
exit 1
}
! [ -z $server ] || {
echo "Usage: $0 server"
exit 1
}
echo "Mounting shares at $server..."
smbclient -L //$server/ -U% | grep Disk > $temp
mnt_dir=$mnt_dir/$server
mkdir -p $mnt_dir
while read share param comment; do
if [ "x$param" == "xDisk" ]; then
# echo "$share"
mkdir -p "$mnt_dir"/"$share"
mount -t smbfs "//$server/$share" "$mnt_dir/$share" -o uid=$UID,codepage=cp1251,iocharset=utf8,guest
fi
done < $temp
rm -f $temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment