Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Put Samba Host IP as Host
- host="192.168.1.10"
- # Desktop Path with trailing slash
- mountpath="/Volumes/mymounts/"
- # Share Username
- username="skata"
- # Share Password
- password="fuck"
- # Shares Names
- shares=("250aris" "gawos" "500gb" "Movies" "Series" "Series-1.5" "raid")
- # Ping the host to see if it exists
- outp=`ping -c 1 $host | grep "0% packet loss"`
- # Based on ping create folders and mount
- # or don't mount and delete folders if they exist
- if [ "$outp" = "1 packets transmitted, 1 packets received, 0.0% packet loss" ]; then
- echo "Found $host, mounting file systems..."
- mount=`mount`
- # echo $mount
- for (( i=0; i<${#shares[*]}; i++ ))
- do
- dir=${mountpath}${shares[$i]}
- share=${shares[$i]}
- # if [ ! -d "$dir1" ]; then
- # # Can't Find Directory So Create It
- # echo "Creating Mount Point: $dir1";
- # mkdir "$dir1"
- # else
- # echo "Found Mount Point: $dir1"
- # fi
- grep=`echo $mount | grep $share`
- # echo $grep
- # echo ${#grep}
- if [ ${#grep} -eq 0 ]; then
- if [ -d "$dir" ]; then
- echo "Mounting $share..."
- mount_smbfs //"$username":"$password"@"$host"/"$share" "$dir"
- fi
- else
- echo "$share already exists"
- fi
- done
- else
- echo "Could not find $host..."
- # dir1=${desktop}${shr1}
- # if [ ! -d "$dir1" ]; then
- # # Can't Find Directory So Do Nothing
- # echo "No Unused Mount Point for $dir1"
- # else
- # echo "Found Unused Mount Point: $dir1"
- # echo "Removing..."
- # rmdir "$dir1"
- # fi
- #
- # dir2=${desktop}${shr2}
- # if [ ! -d "$dir2" ]; then
- # # Can't Find Directory So Do Nothing
- # echo "No Unused Mount Point for $dir2"
- # else
- # echo "Found Unused Mount Point: $dir2"
- # echo "Removing..."
- # rmdir "$dir2"
- # fi
- fi
- # NOTE: If you have other Shell Scripts, or the Teriminal.app is running
- # enabling the next line will cause the entire Terminal.app to close.
- # If you are sure that you can kill the Terminal process feel free to
- # uncomment the following line so that the Terminal window the script brings
- # up will automatically close when finished
- # KillAll Terminal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement