#!/bin/bash # smb.sh -- mount NetFile drives using mount_smbfs ERR_NOARGS=66 ## Determine how many parameters were passed if [[ $# == 0 ]] ; then echo echo "Usage: `basename $0` [share]" echo " mount_smbfs //@fs.nd.edu/ /Volumes/~" echo echo "If no share is passed, the share is assumed to be equal to the username." echo " mount_smbfs //@fs.nd.edu/ /Volumes/~" echo exit $ERR_NOARGS elif [[ $# == 1 || $1 == $2 ]] ; then ## if only one parameter is passed, or if two identical parameters are passed, ## USERNAME and SHARE are the same SHARE=$1 else ## if two different parameters are passed, the second parameter is the SHARE name, preceded by a tilde SHARE=~$2 fi USERNAME=$1 ## echo "\$USERNAME = $USERNAME" ## echo "\$SHARE = $SHARE" MOUNTPOINT="/Volumes/$SHARE" SERVER_ADDR="//$USERNAME@fs.nd.edu/$SHARE" echo "Mounting $SERVER_ADDR to $MOUNTPOINT ..." mkdir -p "$MOUNTPOINT" mount_smbfs "$SERVER_ADDR" "$MOUNTPOINT" open "$MOUNTPOINT" exit 0