Skip to main content
Question

Script to mount SMB share?

  • August 12, 2010
  • 31 replies
  • 96 views

Show first post

31 replies

stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • August 13, 2010

Looking at the mountNetworkShare.sh script, in this case "share" refers to
On Fri, Aug 13, 2010 at 10:13 AM, <josh.glassing at spps.org> wrote:
the share point on the server itself. So yes, in your example, "test" is
what would be put in the share section, or variable.

Steve Wood
Director of IT
swood at integer.com

The Integer Group | 1999 Bryan St. | Ste. 1700 | Dallas, TX 75201
T 214.758.6813 | F 214.758.6901 | C 940.312.2475


Forum|alt.badge.img+21
  • Contributor
  • August 13, 2010

Share is a reference to the actualy share name on the server.

So if you had a path: smb://server.uwec.edu/sharename

Server: server.uwec.edu
Share: sharename

The script creates the local folders that mount will use to mount it to based on that information as well.

Craig E


Forum|alt.badge.img+31
  • Honored Contributor
  • August 13, 2010

so if you wanted to connect to a nested folder under a share point this
is how you should code it

server=10.20.10.20 share=finance_docs

So normally if you hit ? + K and connect to server by typing in
smb://10.20.10.20/finance_docs you need to fill in the share point from
the shared server. So from the resource kit...

# HARDCODED VALUES SET HERE loginUsername="$3" shareUsername="$3"#The username of the user to be used to mount the
share authType="kerberos"#Valid values are "kerberos" (default) or "password"

password=""#Note this only needs to be set if authentication type is
"password" mountType="smb"#The type of file share. Valid types are "afp" (default)
or "smb" serverAddress="10.20.10.20"#The IP address or DNS name of the server -
if left blank, the script will search for the "SMBHome" attribute in the
user record share="finance_docs"#The name of the share you are mounting - if left
blank, the script will search for the "SMBHome" attribute in the user
record

I hope that clears things up and makes sense


Forum|alt.badge.img+12
  • Author
  • Contributor
  • August 13, 2010

Ok, I got my stuff to work, here is what I ended up doing. I ended up creating a policy to have casper run a command at login to mount

sudo -u nameofuser mkdir /Volumes/Test/; sudo -u nameofuser mount -t smbfs //nameofuser:password at server/Test /Volumes/Test

and then another policy to unmount it at logout

umount /Volumes/Test

I was having all sorts of goofy problems tryin to get casper to run the scripts, if I ran the scripts from terminal when I had them locally stored on a machine they ran fine, but when I'd upload them to casper admin and try to run them they'd keep telling me there was an error on line 1 ... I am not sure what the problem is with that, when I get more time I will probably dig into it deeper... but I got stuff working the way I need it to.

Thank you to everyone for your input
-Josh

Re: [Casper] Script to mount SMB share?

Thomas Larkin to:
josh.glassing
08/13/2010 10:26 AM

Cc:
"Lance Ogletree", "Casper List", casper-bounces, "Craig S. Ernst"

so if you wanted to connect to a nested folder under a share point this is how you should code it

server=10.20.10.20 share=finance_docs

So normally if you hit ? + K and connect to server by typing in smb://10.20.10.20/finance_docs you need to fill in the share point from the shared server. So from the resource kit...

# HARDCODED VALUES SET HERE loginUsername="$3" shareUsername="$3"#The username of the user to be used to mount the share authType="kerberos"#Valid values are "kerberos" (default) or "password" password=""#Note this only needs to be set if authentication type is "password" mountType="smb"#The type of file share. Valid types are "afp" (default) or "smb" serverAddress="10.20.10.20"#The IP address or DNS name of the server - if left blank, the script will search for the "SMBHome" attribute in the user record share="finance_docs"#The name of the share you are mounting - if left blank, the script will search for the "SMBHome" attribute in the user record

I hope that clears things up and makes sense


Forum|alt.badge.img+21
  • Contributor
  • August 13, 2010

Permissions problem on the file?

Craig E

On 8/13/10 3:15 PM, "josh.glassing at spps.org" <josh.glassing at spps.org> wrote:

Ok, I got my stuff to work, here is what I ended up doing. I ended up creating a policy to have casper run a command at login to mount

sudo -u nameofuser mkdir /Volumes/Test/; sudo -u nameofuser mount -t smbfs //nameofuser:password at server/Test /Volumes/Test

and then another policy to unmount it at logout

umount /Volumes/Test

I was having all sorts of goofy problems tryin to get casper to run the scripts, if I ran the scripts from terminal when I had them locally stored on a machine they ran fine, but when I'd upload them to casper admin and try to run them they'd keep telling me there was an error on line 1 ... I am not sure what the problem is with that, when I get more time I will probably dig into it deeper... but I got stuff working the way I need it to.

Thank you to everyone for your input
-Josh

Re: [Casper] Script to mount SMB share?

Thomas Larkin to: josh.glassing 08/13/2010 10:26 AM

Cc: "Lance Ogletree", "Casper List", casper-bounces, "Craig S. Ernst"


  • August 16, 2010

I'm a little late here but I've had my own stuff in place for a while and
it's different. Perhaps you could try it and see if it makes a difference.
This is a line from my login script. Without modding, $building is defined
earlier, this gives them the server name and $1 is the current user as far
as OS X is concerned not Casper. I suppose you could just change that to $3
for Casper.

#change focus to current user to run as them
su $1 -c /bin/sh <<EOF
#Make a place to mount the share for the user
mkdir /Volumes/$1
#initiate the Kerberos mount command and attach to the directory we made
just above
mount_afp "afp://;AUTH=Client%20Krb%20v2@"$building"xxx01.domain.org/Users/$1"
/Volumes/$1
#We're done as the current user
EOF

OR, without my building variable

su $1 -c /bin/sh <<EOF
mkdir /Volumes/$1
mount_afp "afp://;AUTH=Client%20Krb%20v2@someserver.domain.org/Users/$1"
/Volumes/$1
EOF

HTH

- JD