Monday, 13 August 2012

Current NHR LIclean.hook

So, after a few years of using NHR I've had to add a few more exceptions. Instead of writing them down I thought I'd might as well just paste the LIclean.hook file here:

#set -xv; exec 1>>/tmp/out 2>&1
PATH=/bin:/usr/bin:/usr/sbin export PATH

#The line above is used for logging and troubleshooting only - if you need to troubleshoot this script, remove the "#" from the line.  Once you are done, put the "#" back at the beginning of the line.
logger "LoginHook: Starting for $1"

#Update on June 27, 2006 - added support for 10.3 clients and other improvements
#Update on July 10, 2006 - added feature so that all local users will bypass redirection.
#Update on October 18, 2006 - added $1 directory in /tmp for better folder structure.
#Update on July 13, 2007 - added Leopard compatibility
#Update on July 19, 2007 - added line to delete Clip Gallery Preferences, if they have not already been removed from the local admin's account.
#Update on April 28, 2008 - took out iHook application, as some users didn't like seeing the iHook window during login.
#Update on August 20, 2008 - due to ACL's put on user home folders starting with 10.5.4, this will now remove the ACL so that redirection can still take place on the folders with Deny Delete ACL's.
#Update on September 3, 2008 - added Office 2008 support
#Update on September 17, 2008 - deleted EOF commands, as it was causing issues with some PPC machines.
#Update on October 5, 2008 - added support for SMART board software, as they store caches in ~/Library/Application Support
#Update on March 5, 2009 - fixed issue with finding local users that matched part of the username (added -x to grep)
#Update on March 11, 2009 - added support for Adobe Acrobat 9
#Update on April 17, 2009 - added support for Adobe CS4
#Update on August 17, 2009 - added support for iMovie 09 with network homes
#Update on September 23, 2009 - added support for users with "." in their shortnames (thanks to Ben Gollmer for this addition)

LocalAdminUser=`dscl . -list /Users uid |grep 501 |awk '{print$1}'`
Local=`dscl . -list /Users |grep -x $1`

#This script will re-direct several folders from a user's network home location to the local machine to help with performance.

if [[ "$1" == "$Local" ]]; then
        exit 0

eval home_loc=~$1

#This section will verify that there are no DENY DELETE ACL's on the folders - and if so, remove the ACL so that redirection can still take place.

aclline=`ls -led "$home_loc"/Library/Caches | grep "deny delete" | head -1 | awk -F: '{print $1}' | sed 's/^[ \t]*//'`
chmod -a# $aclline "$home_loc"/Library/Caches

aclline=`ls -led "$home_loc"/Library/Fonts | grep "deny delete" | head -1 | awk -F: '{print $1}' | sed 's/^[ \t]*//'`
chmod -a# $aclline "$home_loc"/Library/Fonts

aclline=`ls -led "$home_loc"/Library/Application\ Support/SMART\ Technologies\ Inc/Gallery | grep "deny delete" | head -1 | awk -F: '{print $1}' | sed 's/^[ \t]*//'`
chmod -a# $aclline "$home_loc"/Library/Application\ Support/SMART\ Technologies\ Inc/Gallery

#This section will delete the Fonts, Microsoft User Data, AppleWorks User Data, SMART Board Gallery folder and Microsoft Preferences folders from the current user's network home location
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
rm -rf "$home_loc"/Library/Application\ Support/Microsoft/Office
rm -rf "$home_loc"/Library/Application\ Support/SMART\ Technologies\ Inc/Gallery
rm -rf "$home_loc"/Library/Application\ Support/Adobe
rm -rf "$home_loc"/Library/Application\ Support/Google

#This section will clean up the local drive, so that iMovie 09 will work with network homes
rm -rf /iMovie\ Events
rm -rf /iMovie\ Projects

#This section will make a folder for the current user in /tmp
mkdir /tmp/$1/
mkdir /tmp/$1/Adobe
#mkdir /tmp/$1/Adobe/Acrobat
#mkdir /tmp/$1/Adobe/Illustrator\ CS4
mkdir /tmp/$1/Google

#This will copy several Microsoft folders of the local admin user (make sure this account was the first account set up on the client - with UID 501) to /tmp.
cp -R /Users/$LocalAdminUser/Library/Preferences/Microsoft /tmp/$1/Microsoft/
rm -f "/tmp/$1/Microsoft/Clip Gallery Preferences"
cp -R /Users/$LocalAdminUser/Library/Application\ Support/Microsoft/Office /tmp/$1/Office2008
cp -R /Users/$LocalAdminUser/Documents/Microsoft\ User\ Data /tmp/$1/Microsoft\ User\ Data/

#This will create the iMovie 09 folders needed to work with network homes
mkdir "$home_loc"/Movies/iMovie\ Events
mkdir "$home_loc"/Movies/iMovie\ Projects

#This will create an AppleWorks User Data folder in /tmp.
mkdir /tmp/$1/Appleworks

#This will create the user's Caches folder in /tmp.
mkdir /tmp/$1/Caches

#This will check for the Notebook application (SMART) and create a SMART folder in /tmp (if needed).
SMART=`test -e /Applications/Notebook\ Software/ && echo Yes`

if [[ "$SMART" == "Yes" ]]; then
mkdir /tmp/$1/SMART
mkdir -p "$home_loc"/Library/Application\ Support/SMART\ Technologies\ Inc/

#This will change ownership of all files in /tmp/$1 to the current user
chown -R `dscl /Search -read /Users/$1 UniqueID | awk '{print $2}'` /tmp/$1

#This will create the Microsoft and Adobe folders, inside the Application Support folder, for the user.
mkdir "$home_loc"/Library/Application\ Support/Microsoft
#mkdir "$home_loc"/Library/Application\ Support/Adobe

#This last section will set up symbolic links for the current user.
ln -s /tmp/$1/Caches/ "$home_loc"/Library/Caches
ln -s /Library/Fonts/ "$home_loc"/Library/Fonts
ln -s /tmp/$1/Appleworks "$home_loc"/Documents/AppleWorks\ User\ Data
ln -s /tmp/$1/Microsoft/ "$home_loc"/Library/Preferences/Microsoft
ln -s /tmp/$1/Microsoft\ User\ Data/ "$home_loc"/Documents/Microsoft\ User\ Data
ln -s /tmp/$1/Office2008/ "$home_loc"/Library/Application\ Support/Microsoft/Office
ln -s /tmp/$1/SMART/ "$home_loc"/Library/Application\ Support/SMART\ Technologies\ Inc/Gallery
#ln -s /tmp/$1/Adobe/Acrobat/ "$home_loc"/Library/Application\ Support/Adobe/Acrobat
#ln -s /tmp/$1/Adobe/Illustrator\ CS4/ "$home_loc"/Library/Application\ Support/Adobe/Illustrator\ CS4
ln -s /tmp/$1/Adobe/ "$home_loc"/Library/Application\ Support/Adobe
ln -s "$home_loc"/Movies/iMovie\ Events /iMovie\ Events
ln -s "$home_loc"/Movies/iMovie\ Projects /iMovie\ Projects
ln -s /tmp/$1/Google "$home_loc"/Library/Application\ Support/

logger - "LoginHook:  Finished for $1"

#sendLogon extras (IP address and Port number has been taken out)

/usr/bin/sendLogon 123.456.32.1 1234 $1
/usr/bin/sendLogon 123.456.32.2 1234 $1
/usr/bin/sendLogon 123.456.32.3 1234 $1

I've commented out a few lines so I could see what I've done in the past.


so, I've now found that Adobe Bridge has trouble opening. After some investigation it looks like Bridge 4 (CS5) doesn't like symbolic links, but prefers to use the networked folder.

After looking into all the Adobe Applications, the only one now which needs the symbolic link is Adobe Acrobat Pro. So I'm re-writing this script to create a symbolic link from ~/Library/Application Support/Adobe/Acrobat a the local folder.

I'm also getting rid of the Adobe symbolic link so that bridge works.

Addition (08/11/2012)

A few months on and I soon realised that although Illustrator is behaving much better then it did do in the past, I found that if it did not have a symbolic link to the local drive it would have trouble saving and exporting files to the desktop, making it appear that the files were saved, when in fact they had 0kb! This caused a bit of trouble with students at the time, and backups had to be retrieved.

I then added a symlink with ~/Library/Application Support/Adobe/Adobe Illustrator CS5.

I also realised that if it was a new student which didn't have an Application Support folder, NHR would be unable to create an Adobe folder inside this. I hence added a few lines to make the folders:
~/Library/Application Support/
~/Library/Application Support/Adobe/

No comments:

Post a Comment