+ Post New Thread
Results 1 to 12 of 12
Mac Thread, LoginHook to map a couple of network drives in Technical; Can someone please give me a nice script i can use as a loginhook to map network drives on our ...
  1. #1

    Join Date
    Feb 2007
    Location
    Kent
    Posts
    646
    Thank Post
    312
    Thanked 52 Times in 44 Posts
    Rep Power
    40

    LoginHook to map a couple of network drives

    Can someone please give me a nice script i can use as a loginhook to map network drives on our new macs running 10.6

    It's driving me crazy!

    many thanks!

  2. #2
    dayzd's Avatar
    Join Date
    Nov 2009
    Location
    In front of computer
    Posts
    408
    Thank Post
    79
    Thanked 61 Times in 49 Posts
    Rep Power
    26
    What shares are you mapping - are they generic shared folders, or are they individual shares per user?

    The basic command for mapping a share in a bash script is as follows (and assumes you're using AFP filesharing):
    Code:
    #!/bin/bash
    
    # Create a mount point within the filesystem
    mkdir /Volumes/shareName
    # Mount the share to the mount point
    /sbin/mount -t afp afp://your.server/share /Volumes/shareName
    This will mount afp://your.server/share as a volume called shareName

    You'll also need a LogoutHook to unmount the share you added at login:
    Code:
    #!/bin/bash
    
    # Unmount share
    /sbin/umount /Volumes/shareName
    # Delete mount point used from file system
    rmdir /Volumes/shareName

    If you need to map a specific share for a user, LoginHook scripts are passed the current username as $1, so you can use this variable in the path if you require:
    Code:
    #!/bin/bash
    
    mkdir /Volumes/shareName
    /sbin/mount -t afp afp://your.server/$1 /Volumes/shareName
    This will mount afp://your.server/<username> as a volume called shareName


    If you need to use authentication you need to change your share address to something like this
    Code:
    #!/bin/bash
    
    mkdir /Volumes/shareName
    /sbin/mount -t afp afp://username:password@your.server/share /Volumes/shareName
    However, the above will only work if you want to use just one account to mount the share with. You can't have the user enter their password into a loginhook script as it runs. For example, I use the above method to mount a share during the login process to copy some files from the server, before disconnecting at the end of the login script, i.e.:
    Code:
    #!/bin/bash
    
    mkdir /Volumes/loginfiles
    /sbin/mount -t afp afp://serviceuseraccount:serviceuseraccountpassword@your.server/loginfiles /Volumes/loginfiles
    
    # File copying and other stuff happens here
    
    /sbin/umount /Volumes/loginfiles
    rmdir /Volumes/loginfiles

    Also, once you've written your *.sh script, you'll need to make it executable in the Terminal:
    Code:
    chmod +x yourscript.sh
    Hope this gets you started!

  3. #3

    Join Date
    Feb 2007
    Location
    Kent
    Posts
    646
    Thank Post
    312
    Thanked 52 Times in 44 Posts
    Rep Power
    40
    Thankyou, i have their user area mapping using the default options but wanted to map some generic student/staff shared areas too.

  4. #4

    Join Date
    Feb 2007
    Location
    Kent
    Posts
    646
    Thank Post
    312
    Thanked 52 Times in 44 Posts
    Rep Power
    40
    I created the script and made it executable ( or tried and it didn't complain) but when i double click, it just opens in texteditor.

    any ideas?

  5. #5

    Join Date
    May 2006
    Location
    West Bromwich
    Posts
    2,192
    Thank Post
    300
    Thanked 215 Times in 185 Posts
    Rep Power
    57
    Why using login hooks? Can you not just add the shares to the login items using WGM? This is how I mount staff data shares, pupil data shares and an applications share found on the windows server.

    Also you can mount afp shares using Kerberos authentication. Do man mount_afp for the command. I think that's what it is. It's been a while since I looked at this as it was easier using WGM.

  6. #6

    Join Date
    Feb 2007
    Location
    Kent
    Posts
    646
    Thank Post
    312
    Thanked 52 Times in 44 Posts
    Rep Power
    40
    I'm new to this. Didn't really matter how i did it, just needed to figure out how to achieve the end result.
    How would i go about adding my shares to the login items then?

  7. #7

    Join Date
    Feb 2007
    Location
    Kent
    Posts
    646
    Thank Post
    312
    Thanked 52 Times in 44 Posts
    Rep Power
    40
    Never mind! Easy peasy

  8. #8
    MattGibson's Avatar
    Join Date
    May 2008
    Location
    Epsom
    Posts
    183
    Thank Post
    25
    Thanked 16 Times in 11 Posts
    Rep Power
    16
    I know this is an old thread but I'm pretty much in the same boat!

    I ideally would like to use Work Group Manager for adding network shares to my users. Where should I start within WGM?

    I have groups and their docks all setup.

  9. #9

    Join Date
    May 2006
    Location
    West Bromwich
    Posts
    2,192
    Thank Post
    300
    Thanked 215 Times in 185 Posts
    Rep Power
    57
    Go to WGM and then select the group you want to makes changes to.
    Click on preferences along the top
    Click on login
    Click items tab along top to the right
    In finder click go > connect to server.
    Enter the UNC path to the share you want to add
    When it mounts on your desktop drag the icon into the white space in WGM
    Select the share that is now displayed and tick the mount using username and password of user logging in.


    You can't mount a share that is located on the server that is hosting the share. Instead use WGM on a client and then do the same process as above. You may find running WGM on a client makes the process of creating the managed preferences a lot easier.

  10. #10
    MattGibson's Avatar
    Join Date
    May 2008
    Location
    Epsom
    Posts
    183
    Thank Post
    25
    Thanked 16 Times in 11 Posts
    Rep Power
    16
    Hi Everyone,

    Just wondering if you could help me out, I have a AFP share that I need to mount to all desktops but cant seem to get it to work. It works at the root level of the share but I was wondering if I could make it go into a sub-folder with the username of the current logged on user?

    I'm using WGM with the following URL afp://macserver/Network%20Users/ <<This works
    Each user has a folder on the Network Users share with the correct permissions (see screenshot)

    Some websites are suggesting adding $1 to translate the path to afp://macserver/Network%20Users/RMUser01

    I'm by no means a mac man and I appreciate if anyone could advise or a better way of achieving this?

    screenshot.pngscreen.jpg

  11. #11
    dayzd's Avatar
    Join Date
    Nov 2009
    Location
    In front of computer
    Posts
    408
    Thank Post
    79
    Thanked 61 Times in 49 Posts
    Rep Power
    26
    That's how OS X mounts shares - it'll mount directly to the shared folder. You cannot mount a sub-folder of a share.

    I think the $1 trick will only work in a login script, because - as mentioned above - the username is passed to the script as variable '$1'. I don't know if this will work with a WGM-managed share as I never tried it, but if it is going to work, you'll need each individual user folder to be shared individually.

  12. #12
    MattGibson's Avatar
    Join Date
    May 2008
    Location
    Epsom
    Posts
    183
    Thank Post
    25
    Thanked 16 Times in 11 Posts
    Rep Power
    16
    Such a pain, why do they make it so difficult!

    Does anyone know a website that guides me through creating a logon script on Mac OS?



SHARE:
+ Post New Thread

Similar Threads

  1. Map network drives on wireless network
    By woody in forum Windows
    Replies: 24
    Last Post: 1st December 2007, 07:27 PM
  2. Replies: 5
    Last Post: 26th November 2007, 07:40 PM
  3. Map network drives
    By netadmin in forum Scripts
    Replies: 17
    Last Post: 5th April 2007, 04:18 PM
  4. Map network drives
    By timbo343 in forum Scripts
    Replies: 7
    Last Post: 1st March 2007, 07:46 PM
  5. Replies: 7
    Last Post: 27th November 2006, 12:26 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •