OS+X+10.5+Login+Hooks

Upgrading the labs to Leopard meant having to pretty much re-invent this process, as a lot of the commands we used in Tiger no longer functioned as expected. The capture of the username variable became much more difficult in Leopard, and eventually only worked acceptably with the use of a LaunchAgent I found and modified on [|afp548.com], so I have to give credit to them for helping to make this all work. Once the LaunchAgent is dropped into /Library/LaunchAgents, put this shell script in the path you added to the LaunchAgent and it will map your shares:

code format="text" /usr/sbin/kinit -R
 * 1) !/bin/bash
 * 2) Login.sh #############################
 * 3) Modified Aug 7, 2008 - Brian MacPherson ##
 * 4) This script is called from a system LaunchAgent for every user with exception
 * 5) of admin and the system administrator.
 * 6) NOTE the $1 variable no longer outputs the currently logged in user,
 * 7) we get around this by invoking the "id" command
 * 8) Refresh the kerberos ticket
 * 1) Refresh the kerberos ticket

usrname=$(/usr/bin/id -P | awk -F: '{ print $1 }') if [ $usrname != "admin" ] then if [ $usrname != "root" ] then mkdir /Users/$usrname/Desktop/"H Drive" mount_smbfs //$usrname@Server_Name/$usrname$ /Users/$usrname/Desktop/"H Drive" mkdir /Users/$usrname/Desktop/"W Drive" mount_smbfs //$usrname@Server_Name2/$usrname$ /Users/$usrname/Desktop/"W Drive" fi 	fi killall Terminal code And the same for the Logout script code format="text" if ( $usrname != "admin" ) then if ( $usrname != "root" ) then umount /Users/$usrname/Desktop/"H Drive" && rm -rf /Users/$usrname/Desktop/"H Drive" umount /Users/$usrname/Desktop/"W Drive" && rm -rf /Users/$usrname/Desktop/"W Drive" endif endif exit 0 code
 * 1) Set the $usrname variable
 * 1) Lab Logout Script#############################
 * 2) Modified Aug 7, 2008 - Brian MacPherson ##
 * 3) This script executes as a logout hook for every user with exception
 * 4) of admin and the system administrator.
 * 5) This script simply unmounts the smb shares, deletes the mountpoint folders,
 * 6) and removes any trace of the user on the system
 * 7) !/bin/bash
 * 1) !/bin/bash

Updated --1233182295