Results 1 to 4 of 4
  1. #1


    Member Since
    Nov 01, 2011
    Posts
    4
    Question Mapping AFP with Applescript for student macs
    i have spent the past 2 weeks searching google and have also searched these forums and have found standard responses using Automator and drag drive into login items...

    But i need to do this for 100+ macs with over 500 Users who will be logging in using a Microsoft ADS bound to a Mac Snow Leopard Server in the city.local forest.

    We will be rolling out a single mac student image and need help to create a login script on login that will:
    1) mount network drive "cty-mac-stu/Users" using AFP on login

    2) create a folder (on login if it doesnt exist already) under cty-mac-stu/Users with their username (using "whoami") e.g mount the folder afp://cty-mac-stu/Users/bob

    3)make a desktop link of afp://cty-mac-stu/Users/[username] to /Volumes/[username] (using ln -s doesnt work) (is it possible to remove link on logoff???)

    4) change/check the permissions of afp://cty-mac-stu/Users/[username] folder so only that user or an admin can access it on the AFP share

    what I have so far and need help with all 3 items listed above

    1)
    Code:
    set MyName to do shell script "whoami"
    tell application "Finder"
    try
    mount volume "afp://" & MyName & "@cty-mac-stu/" & MyName & "/ /Volumes/" & MyName & "/"
    on error
    display dialog  "There was an error mounting the Volume " & MyName & return & return & "Please inform the support staff if the problem continues after a reboot." buttons {"Okay"} default button 1
    end try
    end tell
    2) no idea how to do this
    3) no idea
    4) no idea

    any help on this would greatly reduce my stress levels and i'm sure would help a lot of people

  2. #2


    Member Since
    Nov 01, 2011
    Posts
    4
    i have fixed some issues;
    i can now login and it mounts after the user inputs their login details
    i can create a link to the desktop to their user folder

    at the moment i cannot find a way to change the permissions of the folder upon creation, e.g since we wipe the share folder every friday at 10pm the users would need to recreate their folders upon next login automatically, at this point i would like the permissions set to only allow the current user access (and admins)

    also looking into LogoutHook to remove the mounted drives+volumes

    any ideas and hints/links are welcome

    code for the working login script currently:
    Code:
    set MyName to do shell script "whoami"
    tell application "Finder"
    try
    mount volume "afp://" & MyName & "@cty-mac-stu/" & MyName & "/ /Volumes/" & MyName & "/"
    on error
    display dialog  "There was an error mounting the Volume " & MyName & return & return & "Please inform the support staff if the problem continues after a reboot." buttons {"Okay"} default button 1
    end try
    end tell

  3. #3


    Member Since
    Nov 01, 2011
    Posts
    4
    what i have so far, the first script works when run manually, but when i look closer i find that it stalls if a folder exists on the /Users/ network share, but runs fine if that folder is missing.

    is there a way to suppress that error, or skip it if the folder exists?

    Login Script

    set MyName to do shell script "whoami"
    set MountFolder to POSIX file "Volumes/Users/"

    tell application "Finder"
    try
    -- mount volume "afp://" & MyName & "@cty-mac-stu/Users/ /Volumes/Users/" & MyName & "/"
    delay 5
    if (exists folder MyName of MountFolder) is true then
    make new folder at MountFolder with properties {name:MyName}
    end if
    delay 5
    do shell script "ln -s /Volumes/Users/" & MyName & " ~/Desktop"
    delay 3
    do shell script "/bin/chmod 0700 /Volumes/Users/" & MyName & ""
    end try
    end tell
    Logoff Script
    set MyName to do shell script "whoami"
    try
    do shell script "/bin/chmod 0700 /Volumes/Users/" & MyName & ""
    do shell script "rm ~/Desktop/" & MyName & ""
    delay 3
    do shell script "hdiutil eject -force /Volumes/Users "
    end try

  4. #4


    Member Since
    Nov 01, 2011
    Posts
    4
    Thumbs up [solved]
    ok i have managed to do it on my own, i will post the scripts here to help anyone that may need it in the future.
    I firstly used a program called Login Logout tasks which loads on startup and executes the login scpt file, and when it closes it executes the logout scpt file. you put this script under Accounts -> Login Items, i renamed mine to Network Mapping so users dont close it accidentally.

    Login Script
    Code:
    set MyName to do shell script "whoami"
    set MountFolder to POSIX file "/Volumes/Users/"
    
    tell application "Finder"
    	try
    		mount volume "afp://" & MyName & "@cty-mac-stu/Users/ /Volumes/Users/" & MyName & "/"
    		mount volume "afp://" & MyName & "@cty-mac-stu/common/ /Volumes/common/"
    		delay 2
    		if (exists folder MyName of MountFolder) is false then
    			make new folder at MountFolder with properties {name:MyName}
    			delay 3
    			do shell script "ln -s /Volumes/Users/" & MyName & " ~/Desktop"
    			do shell script "ln -s /Volumes/common ~/Desktop"
    			delay 1
    			do shell script "/bin/chmod 0774 /Volumes/Users/" & MyName & ""
    			do shell script "/bin/chmod 444 ~/Documents"
    			do shell script "/bin/chmod 444 ~/Movies"
    			do shell script "/bin/chmod 444 ~/Music"
    			do shell script "/bin/chmod 444 ~/Pictures"
    			do shell script "/bin/chmod 444 ~/Public"
    			do shell script "/bin/chmod 444 ~/Sites"
    		end if
    	on error
    		delay 3
    		do shell script "ln -s /Volumes/Users/" & MyName & " ~/Desktop"
    		do shell script "ln -s /Volumes/common ~/Desktop"
    		delay 1
    		do shell script "/bin/chmod 0774 /Volumes/Users/" & MyName & ""
    		do shell script "/bin/chmod 444 ~/Documents"
    		do shell script "/bin/chmod 444 ~/Movies"
    		do shell script "/bin/chmod 444 ~/Music"
    		do shell script "/bin/chmod 444 ~/Pictures"
    		do shell script "/bin/chmod 444 ~/Public"
    		do shell script "/bin/chmod 444 ~/Sites"
    	end try
    end tell
    Logout Script
    Code:
    set MyName to do shell script "whoami"
    do shell script "/bin/chmod 0774 /Volumes/Users/" & MyName & " > dev/null 2>&1 &"
    do shell script "rm ~/Desktop/" & MyName & " > dev/null 2>&1 &"
    do shell script "rm ~/Desktop/common > dev/null 2>&1 &"
    delay 3
    do shell script "hdiutil eject -force /Volumes/Users"
    do shell script "hdiutil eject -force /Volumes/common"

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Afp
    By Khorrocks in forum OS X - Operating System
    Replies: 1
    Last Post: 10-24-2012, 01:43 PM
  2. Fileshare networking between Macs/AFP
    By admirestudios in forum OS X - Operating System
    Replies: 3
    Last Post: 04-22-2012, 06:30 PM
  3. Ftp/afp
    By leopard-user1 in forum Running Windows (or anything else) on your Mac
    Replies: 1
    Last Post: 10-26-2009, 06:53 PM
  4. Student Macs
    By utchin in forum Schweb's Lounge
    Replies: 18
    Last Post: 02-22-2009, 10:07 AM
  5. any new updated student discounts or future student promotions??
    By wrightm in forum Apple Rumors and Reports
    Replies: 12
    Last Post: 06-28-2005, 05:33 PM

Posting Permissions

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