Created
February 7, 2011 22:02
-
-
Save andy722/815330 to your computer and use it in GitHub Desktop.
Mount all shares of SMB server
This file contains 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 | |
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