[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sambaa (FIXED)



On Fri, 2002-06-28 at 23:55, Dave Price wrote:
> smbmount //wren/public /home/public -o username=davep password=davespass

I got tired of:

mount -t smbfs -o blah blah blah blah..
mount: directory doesn't exist

So I wrote a little shell script to create a hierarchy of samba shares
when I mount them if they don't exist.  So basically:

smb NT_username NT_workgroup NT_server NT_share
password: <enter your password>

will create /mnt/NT_server/NT_share with the uid/gid of the caller.  It
also relies on sudo.

Jeremy

-- 
**************************************************************
Jeremy M Turner, A+ Technician             Phone: 405.425.5555
Email: Jeremy.Turner@oc.edu                Phone: 405.425.1820
Information Technology Services, Oklahoma Christian University
**************************************************************
Fortune:
What good is an obscenity trial except to popularize literature?
		-- Nero Wolfe, "The League of Frightened Men"
**************************************************************
#!/bin/sh
#
# Jeremy's script to mount samba shares
# -------------------------------------
# This script takes 4 arguments, and mounts a samba
# share based on the arguments:
#  $1 = The NT user to authenticate as
#  $2 = The NT workgroup
#  $3 = The NT server
#  $4 = The NT share on the server
#
# The script takes the NT share:
#   \\$3\$4 
# and mounts it as:
#   SMB_BASE/$3/$4

# Check for the existance of sudo
test -x /usr/bin/sudo || exit 0

# Where do you want to mount the shares?
SMB_BASE=/mnt

# Mount the directory as uid and gid as current user
#   so that the current user 
WHO_AM_I=`whoami`

# Mount the directory as user 
SMB_USER=$1

# Mount the directory as workgroup
SMB_WORKGROUP=$2

# Mount a share from this server
SMB_SERVER=$3

# Mount this share from server
SMB_SHARE=$4

# Generate the remote UNC path
SMB_SERVER_SHARE="//$SMB_SERVER/$SMB_SHARE"

# Generate the local mount path
SMB_MOUNT_POINT="$SMB_BASE/$SMB_SERVER/$SMB_SHARE"

# If the base mount point directory does exist, create it
test -d $SMB_BASE || sudo mkdir $SMB_BASE

# If the server mount point directory doesn't exist, create it
test -d $SMB_BASE/$SMB_SERVER || sudo mkdir $SMB_BASE/$SMB_SERVER

# If the mount point directory doesn't exist, create it
test -d $SMB_MOUNT_POINT || sudo mkdir $SMB_MOUNT_POINT

# Mount the samba share
sudo mount -t smbfs \
 -o uid=$WHO_AM_I,gid=$WHO_AM_I,username=$SMB_USER,workgroup=$SMB_WORKGROUP \
 $SMB_SERVER_SHARE $SMB_MOUNT_POINT

Reply to: