Using FontExplorer X With Networked Home Directories

Font­Ex­plorer X has some really funky behav­ior when it comes to users with net­worked home direc­to­ries. Nor­mally, the appli­ca­tion files for Font­Ex­plorer are stored in ~/Library/Application Support/Linotype/FontExplorer X/. Every­thing works fine and dandy…until a user with a net­worked home direc­tory tries to open in.

When a user with a net­worked home folder tries to open the Font­Ex­plorer X, the file ~/Library/Application Support/Linotype/FontExplorer X/FontDatabase.db is made into an alias. Note that this is a rather impor­tant file. It appears to store the ref­er­ences to all of your fonts (not the fonts them­selves, just the ref­er­ences). The alias points to a newly cre­ated FontDatabase.db file in /Users/Shared/Linotype/FontExplorer X/<username>_<uid>/, where <username> is the user­name of the cur­rent user and <uid> is the user id of the cur­rent user.

The end result of this behav­ior, is that Font­Ex­plorer behaves as if it’s the first time Font­Ex­plorer X has been opened, every time some­one uses it. Of course, in a lab type envi­ron­ment this behav­ior is com­pletely unacceptable.

Below are login/logout scripts that I wrote to cir­cum­vent this behav­ior. You can down­load the scripts and a readme.txt file here:

Update: I should point out here that this par­tic­u­lar script has only been tested on OS X 10.4 (Tiger). It will work on 10.3, but the way that you set up the login hook is slightly dif­fer­ent than what I describe below. I’m also using FEX 1.2.2 for this script and it should be noted that the way FEX stores it’s data­base changed slightly in this ver­sion. Pre­vi­ous ver­sions of FEX should work with this script using only a small tweak­ing. As I have not gotten my hands on a Leop­ard yet, I have no idea if this will work with them. (added 11/8/2007)

Update #2: This script is still work­ing like a charm using OS X 10.5.4 and FEX 1.2.3. (added 8/12/2008)

The Setup

  1. Start by set­ting up FEX on a test com­puter. Set all the pref­er­ences as you want them and make sure the fonts are imported into appro­pri­ate sets.
  2. Font Library: Make a copy of your entire font library and note the loca­tion it’s stored in. I use /Users/Shared/Font Explorer X/ so that every­body has access to it.
  3. FEX plist: make a copy of the FEX plist file located in /Users/<username>/Library/Preferences/com.linotype.FontExploereX.plist
  4. Appli­ca­tion Sup­port Files: Make a copy of the Lino­type appli­ca­tion sup­port folder located in /Users/<username>/Library/Application Support/
  5. A copy of each of these must reside on the client com­puter (the one your run­ning the login script on).
    • Make sure that the entire font library is in the same loca­tion on the client com­puter as it was in the test machine (/Users/Shared/ in my case).
    • Copy the FEX plist and Lino­type folder to a priv­i­leged loca­tion on the client com­puter. It doesn’t matter where they are, we just don’t want normal users to be able to modify them. I use an admin’s doc­u­ment folder.’
  6. Change the $backupprefs and $backupdb vari­ables in login.sh to the cor­rect loca­tions. They should be lines 11 and 14.

Installation

  1. Copy login.sh and logout.sh to client com­put­ers. Make sure that you limit access to the files. They will be run as root, so these per­mis­sions will work:
    
    sudo chown root:admin <pathToFile>/login.sh <pathToFile>/logout.sh
    sudo chmod 750 <pathToFile>/login.sh <pathToFile>/logout.sh
    
  2. Add the login and logout hooks. Run these two com­mands in the ter­mi­nal of the client com­puter:
    
    sudo defaults write com.apple.loginwindow LoginHook <pathToFile>/login.sh
    sudo defaults write com.apple.loginwindow LogoutHook <pathToFile>/logout.sh
        

    Note: This works on 10.4. The syntax for 10.3 might be slightly different
  3. To test to make sure the hooks got set up cor­rectly, run this com­mand and ensure that the direc­to­ries are cor­rect:
    sudo defaults read com.apple.loginwindow

Adding to Existing Login and Logout Hooks

If you already have login and logout scripts run­ning, simply append the con­tents of these scripts to your exist­ing ones. Every­thing should still work fine.

Login.sh


#!/bin/sh

### Modify these ###
# change to location where you put FEX plist file
backupprefs="/Users/admin/Documents/com.linotype.FontExplorerX.plist"
# change to location where you put Linotype file
backupdb="/Users/admin/Documents/Linotype"


### Start of Script ###
# Get the shortname of user who just logged in
username=$1

# create hidden file containing username for the logout script
echo $username > /Users/.username

# get the user id of user who just logged in
userid=`su - $username -c "/usr/bin/id -u"`

# set a variable for the FontExplorer folder in the format of _
userfolder=${username}_${userid}

# get the path to the networked home directory of user
userhome=`su - $username -c "/usr/bin/id -P | cut -f9 -d:"`

# Make the prefs directory in /Users/Shared/ for networked users
mkdir -p "/Users/Shared/Linotype/FontExplorer X/$userfolder/"

# On the rare occassion that the logout script fails to copy the FontDatabase.db file back to user's folder,
# this will copy in a default backup copy of the FontDatabase.db file 
if [ ! -e "$userhome/Library/Application Support/Linotype/FontExplorer X/FontDatabase.db" ]; then
 cp -R $backupdb "$userhome/Library/Application Support/"
 chown -R $username:$username "$userhome/Library/Application Support/Linotype/"
fi

# Copy the real FontDatabase.db file from user's home to the /Users/Shared location
cp "$userhome/Library/Application Support/Linotype/FontExplorer X/FontDatabase.db" "/Users/Shared/Linotype/FontExplorer X/$userfolder/"

# Set the ownership and permissions on the /Users/Shared/Linotype/ directory
chown -R $username:$username /Users/Shared/Linotype/
chmod -R 700 /Users/Shared/Linotype/

# Copy correct user preferences (users can't break them)
# Don't need to do this step, but helpful in making sure correct prefs are always set
cp $backupprefs "$userhome/Library/Preferences/com.linotype.FontExplorerX.plist"
chown $username:$username "$userhome/Library/Preferences/com.linotype.FontExplorerX.plist"
chmod 700 "$userhome/Library/Preferences/com.linotype.FontExplorerX.plist"

Logout


#!/bin/sh

# Get username of current user
username=`cat /Users/.username`


### Start of Script ###
# get the user id of current user
userid=`su - $username -c "/usr/bin/id -u"`

# set a variable for the FontExplorer folder in the format of _
userfolder=${username}_${userid}

# get the path to the networked home directory of user
userhome=`su - $username -c "/usr/bin/id -P | cut -f9 -d:"`

# Remove the sym link version of FontDatabase.db in user's home
rm "$userhome/Library/Application Support/Linotype/FontExplorer X/FontDatabase.db"

# Copy version of FontDatabase.db from /Users/Shared/ back to user's home
cp "/Users/Shared/Linotype/FontExplorer X/$userfolder/FontDatabase.db" "$userhome/Library/Application Support/Linotype/FontExplorer X/FontDatabase.db"
# Make sure ownership is correct
chown -R $username:$username "$userhome/Library/Application Support/Linotype/"

# Remove all of the user's Linotype directories from the /Users/Shared/ directory
rm -R /Users/Shared/Linotype

Cheers.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Comments

1. Beth Norconk

Thank you so much.

I can not tell you how crazy this pro­gram was making me.

I had to change the scripts for my envi­ron­ment but it is now work­ing for the 2 stu­dent net­work ids that I have tried so far.

Now to deploy it into the lab.

Thanks, Beth

Beth Norconk

2. Alissa Miller

@Beth

I’m glad that the script helped you! Let me know how it goes and if you have any ques­tions about using it. Ques­tions, com­ments and improve­ments on the script are all welcome.

Leave a Reply