[MacTUG] login hook "stuff" as mentioned at the meeting
Ian Turner
iturner at uwaterloo.ca
Tue Sep 28 12:25:45 EDT 2010
we started with the NHR package, several years ago (and several versions
ago), and received permission from the original author to adapt it for
our use
http://jochsner.dyndns.org/scripts/NHR.html
In particular, we didn't "upgrade", to the new Leopard Package, but
retrofitted some of the Unix level changes to our original scripts.
Then of course, with Leopard, we actually "removed" the "Home
Redirector" part of the code, because we are using the "built in to Open
Directory/WorkGroup Manager" functionality.
***** NOTE: there was some "old code" that I was remembering for su'ing
as the local user, but has not been in use for a long time; now it just
runs as root.
- a sample fragment:
-------snip---------
#This section will delete the Fonts, Microsoft User Data, AppleWorks
User Data, and Microsoft Preferences folders from the current user's
network home location
su $1 -cf /bin/sh <<EOF
rm -rf $home_loc/Library/Caches
rm -rf $home_loc/Library/Fonts
rm -rf $home_loc/Documents/Microsoft\ User\ Data
rm -rf $home_loc/Documents/AppleWorks\ User\ Data
rm -rf $home_loc/Library/Preferences/Microsoft
EOF
----------snip---------------
Sample code:
***************************** this is an excerpt from the beginning, of
current code****************************************************
#!/bin/sh
PATH=/bin:/usr/bin:/usr/sbin export PATH
logger "LoginHook: Starting for $1"
# Aug 25, 2008 - LocalAdminUser no longer required, and nicl not
supported in Leopard
#Local=`nicl . -read /users/$1 name |awk '{print $2}'`
Local=`dscl . -list /Users | grep $1`
if [[ "$1" == "$Local" ]]; then
exit 0
fi
eval home_loc=~$1
#This section will create a skeleton DrJava config file if one does not
exist
# (assumed to be for new users, or to fix a broken one)
cd ${home_loc}
if [[ -f ${home_loc}/.drjava ]]; then
echo ".drjava exists"
else
echo 'working.directory = '`echo ${home_loc}` > ${home_loc}/.drjava
fi
#This section will create ~/.MacOSX/environment.plist if it does not
exist, and configure XAUTHORITY
cd ${home_loc}
#if [[ -f ${home_loc}/.MacOSX/environment.plist ]]; then
# echo "environment.plist exists"
#else
if [[ -d ${home_loc}/.MacOSX ]]; then
echo ".MacOSX exists"
else
mkdir .MacOSX
fi
#fi
#changed logic because Ed also needs this file to configure CS200 for
Web and Database
# so append these lines unconditionally
#Oct 15, 2007 change lib to lib32 in SQL10 Library Path
#Aug 25, 2008 remove SQL version 9
#Sep 19, 2008 clear XAUTH Leopard different than Tiger; and remove old
unnecessary lock files
cd ${home_loc}
rm .Xauthority-*
#
defaults write ${home_loc}/.Macosx/environment "XAUTHORITY"
"${home_loc}/.Xauthority-mac"
# defaults delete ${home_loc}/.Macosx/environment "XAUTHORITY"
defaults write ${home_loc}/.Macosx/environment "SQLANY10"
"/Applications/SQLAnywhere10/System"
defaults write ${home_loc}/.Macosx/environment "SQLANYSH10"
"/Applications/SQLAnywhere10/System"
defaults write ${home_loc}/.Macosx/environment "DYLD_LIBRARY_PATH"
"/Applications/SQLAnywhere10/System/lib32:"
defaults write ${home_loc}/.Macosx/environment "PATH"
"/Applications/SQLAnywhere10/System/sybcentral500:/Applications/SQLAnywhere10/System/bin32:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/libexec/binutils:"
plutil -convert xml1 ${home_loc}/.Macosx/environment.plist
------snip-----------------
logger - "LoginHook: Finished for $1"
#Remember to run a logout hook that will delete the contents of /tmp
# (sudo defaults write com.apple.loginwindow LogoutHook /path/to/script)
More information about the MacTUG
mailing list