Use scripts to improve install process for Lotus Notes

Nov 20, '08 07:30:00AM

Contributed by: MrLint

For those of us who must use Lotus Notes (LN) on Mac OS X, it is the bane of our existence. The installer is basically broken, and it's not configured for multi-user setup. But today, all that changes! I have devised a series of procedures to make LN easier to install, and also to make it "multi-user aware." These notes are known to work with LN 7.0.3, but may work with any R7 flavor, and may be able to be altered for 6.5.6, which is the last 6.5x version for OS X.

Some of the problems with the LN installer :

  1. Sometimes LN does not ask for authorization
  2. Running as a non-admin user does not work correctly
  3. Only installs the templates and seed files (referred to as seed files) to the directory of the account that installed it.
The third one is really a problem. The installer assumes that the person who is going to use LN is the same person who installed it, and to install it, you need to be an admin. Read on to see how I fixed this mess...

A successful install of LN consists of three "parts:"

  1. The Notes.app in /Applications
  2. The "seed" files in $HOME/Library/Application Support/Lotus Notes Data
  3. Preferences (Notes Preferences -- plain text dropped by the installer -- and com.ibm.notes.plist -- made by the app after user setup, and safe to ignore).
To get this to work you need to just zip up the app, seeds and prefs, but as with any hint, there are some tricks, too.

Create a folder called Lotus Notes Data, and copy the contents of the seed folder. It is safe to delete modem files and any languages you aren't going to use from the dic folder. Create a custom Notes Preferences file with the following contents:
[Notes]
SharedDataDirectory=/Library/Application Support/Lotus Notes Data
The installed Notes Preferences file is loaded up with lots of junk, mostly things that the application will recreate later during user setup. The new directive will tell the client to look in the specified path for any templates it needs, instead of assuming it's in the path the installer dropped it in -- this is critical for this to work.

Zip up that folder in Terminal, as using the Finder's zip will add a bunch of metadata that will cause the script later on to flake out. Call it ln_current_seed.zip. While in Terminal, also zip up the Notes.app in /Applications and call it ln_current_app.zip. Put these two files up on your favorite internal web server for later deployment.

The next secret is the deployment. To outline:
  1. Download, unzip the files and maint seeds to /Library » Application Support, and the application to /Applications.
  2. Drop Notes Preferences to default user, and maint to /System » Library » User Template » English.lproj » Library » Preferences.
  3. Clean up.
Here's the script to do all that; it contains some error checking:
#!/bin/bash


USER_PREFS="0"
GOOD_SHARED_DIR="0"
MAJ_VER="0"

# get OS kernel version

#VERSION=$(sysctl -n kern.osrelease)
MAJ_VER=$(sysctl -n kern.osrelease | cut -d . -f 1)

if ! [ "$MAJ_VER" -ge "8" ]
then
	echo "Lotus Notes 7 requires Mac OS X 10.4.X or later."
	read -p "Press any key to exit"
	exit
fi

# does the user have LN prefs?
if  [ -e ~/Library/Preferences/Notes\ Preferences ]
then
	USER_PREFS="1"
fi


if [ -e /Library/Application\ Support/Lotus\ Notes\ Data/Notes\ Preferences ]
then
	GOOD_SHARED_DIR="1"
fi




cd /var/tmp

#get files
#need to suppress progress
echo "Retrieving files"
curl -O http://your.web.server/ln_current_app.zip

if  [ "$GOOD_SHARED_DIR" -ne "1" ]
then
	#Cleanup bad setup
	sudo rm -rf /Library/Application\ Support/Lotus\ Notes\ Data
	#get files
	curl -O http://your.web.server/ln_current_seed.zip
	
	#uncompress seeds 
	echo "Installing templates"
	unzip -o ln_current_seed.zip -d /Library/Application\ Support/
	
	echo "Correcting permissions"
	sudo chmod -R 755 /Library/Application\ Support/Lotus\ Notes\ Data
fi


#drop prefs for all new users
echo "Installing multi-user prefs for new users"
sudo mkdir /System/Library/User\ Template/English.lproj/Library/Application\ Support/Lotus\ Notes\ Data
sudo cp -f /Library/Application\ Support/Lotus\ Notes\ Data/Notes\ Preferences /System/Library/User\ Template/English.lproj/Library/Preferences/Notes\ Preferences

#drop app & fix perms
echo "Installing Application"
unzip -o ln_current_app.zip -d /Applications/
echo "Correcting permissions and ownership"
sudo chown -R root:admin /Applications/Notes.app/
sudo chmod -R 775 /Applications/Notes.app/

#cleanup
echo "Cleaning up"
rm ln_current_app.zip
rm ln_current_seed.zip

exit


#drop prefs for current user
if [ "$USER_PREFS" -ne "1" ]
then
	echo "Dropping multi user prefs for current user"
	mkdir ~/Library/Application\ Support/Lotus\ Notes\ Data
	cp /Library/Application\ Support/Lotus\ Notes\ Data/Notes\ Preferences ~/Library/Preferences/Notes\ Preferences
	echo "Launch the Notes application and preceed with normal configuration."
fi

read -p "Press any key to exit"
exit
This is great for a brand new deployment, because new users will get the files they need to just run the app and you (the tech) can do the setup. But if you are putting this out on a system in which users already exist, you need also run the following script. This will prep the profile for the currently logged in user.
#!/bin/bash

USER_PREFS="0"
GOOD_SHARED_DIR="0"
MAJ_VER="0"

# get OS kernel version

#VERSION=$(sysctl -n kern.osrelease)
MAJ_VER=$(sysctl -n kern.osrelease | cut -d . -f 1)

if ! [ "$MAJ_VER" -ge "8" ]
then
	echo "Lotus Notes 7 requires Mac OS X 10.4.X or later."
	read -p "Press any key to exit"
	exit
fi

# does the user have LN prefs?
if  [ -e ~/Library/Preferences/Notes\ Preferences ]
then
	USER_PREFS="1"
fi


if [ -e /Library/Application\ Support/Lotus\ Notes\ Data/Notes\ Preferences ]
then
	GOOD_SHARED_DIR="1"
fi


if  [ "$GOOD_SHARED_DIR" -ne "1" ]
then
	echo "Lotus Notes is not yet set up correctly. Contact CSS."
	echo "ERROR - Shared directory not set up"
else

	echo "Multi user setup appears correct"
	
	#drop prefs for current user
	if [ "$USER_PREFS" -ne "1" ]
	then
		echo "Dropping multi user prefs for current user"
		mkdir ~/Library/Application\ Support/Lotus\ Notes\ Data
		cp /Library/Application\ Support/Lotus\ Notes\ Data/Notes\ Preferences ~/Library/Preferences/Notes\ Preferences
		defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Notes.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
		killall -HUP Dock
		echo "Launch the Notes application and preceed with normal configuration."
	fi
fi

read -p "Press any key to exit"
exit
Notes: [robg adds: I haven't tested this one. Please note there are some sudo rm -rf... commands in the scripts -- please triple-check the code before using!]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20081114130330704