#!/bin/sh
#
# Title:  Thunderbird Autoconfig Setup Script
# Author: Charles Dominguez (cfdoming)
# Description:
#	Configures autoconfig for all installed Firefox versions.
#
# Change Log:
#    2004-04-08  cfdoming  Initial version.
#		


# Name of the autoconfig file
autocfgFile='mit.cfg'

# Have all installed Thunderbird versions reference the callfile
for file in /mit/firebird/arch/*/.build/MozillaThunderbird*/defaults/pref/all.js \
            /mit/firebird/arch/*/.build/MozillaThunderbird*/greprefs/all.js; do


	# If the preference already exists, change it
	if grep "pref(['\"]general.config.filename['\"]," $file > /dev/null 2>&1 ; then
        
		rm -f $file.new
		
		sed -e "s|pref(['\"]general.config.filename['\"],.*\?);|pref('general.config.filename', '$autocfgFile');|" \
			$file > $file.new \
			&& mv -f $file.new $file
			
	else # otherwise, add it to the end.
	
		echo "pref('general.config.filename', '$autocfgFile');" >> $file
	
	fi



done

# create link to callfile in each $MOZILLA_HOME
for dir in /mit/firebird/arch/*/.build/MozillaThunderbird*; do

	ln -sf "/afs/sipb.mit.edu/project/firebird/arch/share/bin/MozillaThunderbird/autoconfig/$autocfgFile" "$dir/$autocfgFile"

done
	

