New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Mapping AFP with Applescript for student macs


Post Reply New Thread Subscribe

 
Thread Tools
DrunkMunki

 
Member Since: Nov 01, 2011
Posts: 4
DrunkMunki is on a distinguished road

DrunkMunki is offline
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
QUOTE Thanks
DrunkMunki

 
Member Since: Nov 01, 2011
Posts: 4
DrunkMunki is on a distinguished road

DrunkMunki is offline
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
QUOTE Thanks
DrunkMunki

 
Member Since: Nov 01, 2011
Posts: 4
DrunkMunki is on a distinguished road

DrunkMunki is offline
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

Quote:
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
Quote:
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
QUOTE Thanks
DrunkMunki

 
Member Since: Nov 01, 2011
Posts: 4
DrunkMunki is on a distinguished road

DrunkMunki is offline
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"
QUOTE Thanks

Post Reply New Thread Subscribe


« Time Machine Share External Drive With PC? | How do i get from Tiger 10.4.11 to OSX Leopard 10.5.8? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
new to networking on macs jdevleerjr OS X - Operating System 1 07-22-2007 04:17 PM
Shouldn't we be promoting other users not to go for Macs insteads y04chs067 Schweb's Lounge 30 06-22-2007 07:18 AM

All times are GMT -4. The time now is 01:58 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?