a8a561
#!/bin/sh
a8a561
#
a8a561
# The contents of this file are subject to the Netscape Public
a8a561
# License Version 1.1 (the "License"); you may not use this file
a8a561
# except in compliance with the License. You may obtain a copy of
a8a561
# the License at http://www.mozilla.org/NPL/
a8a561
#
a8a561
# Software distributed under the License is distributed on an "AS
a8a561
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
a8a561
# implied. See the License for the specific language governing
a8a561
# rights and limitations under the License.
a8a561
#
a8a561
# The Original Code is mozilla.org code.
a8a561
#
a8a561
# The Initial Developer of the Original Code is Netscape
a8a561
# Communications Corporation.  Portions created by Netscape are
a8a561
# Copyright (C) 1998 Netscape Communications Corporation. All
a8a561
# Rights Reserved.
a8a561
#
a8a561
# Contributor(s): 
a8a561
#
a8a561
a8a561
## 
a8a561
## Usage:
a8a561
##
a8a561
## $ thunderbird
a8a561
##
a8a561
## This script is meant to run a mozilla program from the mozilla
a8a561
## rpm installation.
a8a561
##
a8a561
## The script will setup all the environment voodoo needed to make
a8a561
## mozilla work.
a8a561
a8a561
cmdname=`basename $0`
a8a561
a8a561
# BEAST fix
a8a561
NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
a8a561
export NSS_SSL_CBC_RANDOM_IV
a8a561
a8a561
##
a8a561
## Variables
a8a561
##
a8a561
MOZ_ARCH=$(uname -m)
a8a561
case $MOZ_ARCH in
a8a561
	x86_64 | s390x | sparc64)
a8a561
		MOZ_LIB_DIR="/usr/lib64"
a8a561
		SECONDARY_LIB_DIR="/usr/lib"
a8a561
		;;
a8a561
	* )
a8a561
		MOZ_LIB_DIR="/usr/lib"
a8a561
		SECONDARY_LIB_DIR="/usr/lib64"
a8a561
		;;
a8a561
esac
a8a561
a8a561
if [ ! -x $MOZ_LIB_DIR/thunderbird/thunderbird ]; then
a8a561
    if [ ! -x $SECONDARY_LIB_DIR/thunderbird/thunderbird ]; then
a8a561
        echo "Error: $MOZ_LIB_DIR/thunderbird/thunderbird not found"
a8a561
        if [ -d $SECONDARY_LIB_DIR ]; then
a8a561
            echo "       $SECONDARY_LIB_DIR/thunderbird/thunderbird not found"
a8a561
        fi
a8a561
        exit 1
a8a561
    fi
a8a561
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
a8a561
fi
a8a561
a8a561
MOZ_DIST_BIN="$MOZ_LIB_DIR/thunderbird"
a8a561
MOZ_PROGRAM="$MOZ_DIST_BIN/thunderbird"
a8a561
MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
a8a561
MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}"
a8a561
a8a561
##
a8a561
## Set MOZ_ENABLE_PANGO is no longer used because Pango is enabled by default
a8a561
## you may use MOZ_DISABLE_PANGO=1 to force disabling of pango
a8a561
##
a8a561
#MOZ_DISABLE_PANGO=1
a8a561
#export MOZ_DISABLE_PANGO
a8a561
a8a561
##
a8a561
## Set MOZ_APP_LAUNCHER for gnome-session
a8a561
##
a8a561
export MOZ_APP_LAUNCHER="/usr/bin/thunderbird"
a8a561
a8a561
##
a8a561
## Disable the GNOME crash dialog, Moz has it's own
a8a561
## 
a8a561
GNOME_DISABLE_CRASH_DIALOG=1
a8a561
export GNOME_DISABLE_CRASH_DIALOG
a8a561
a8a561
##
a8a561
## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
a8a561
## in your environment before launching Firefox.
a8a561
##
a8a561
#
a8a561
# MOZ_DISABLE_LANGPACKS=1
a8a561
# export MOZ_DISABLE_LANGPACKS
a8a561
#
a8a561
a8a561
##
a8a561
## Automatically installed langpacks are tracked by .fedora-langpack-install
a8a561
## config file.
a8a561
##
a8a561
FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
a8a561
a8a561
# MOZ_DISABLE_LANGPACKS disables language packs completely
a8a561
MOZILLA_DOWN=0
a8a561
if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
a8a561
    pidof thunderbird > /dev/null 2>&1
a8a561
    MOZILLA_DOWN=$?
a8a561
fi
a8a561
a8a561
# Modify language pack configuration only when thunderbird is not running 
a8a561
# and language packs are not disabled
a8a561
if [ $MOZILLA_DOWN -ne 0 ]; then
a8a561
a8a561
    # Clear already installed langpacks
a8a561
    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
a8a561
    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
a8a561
        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
a8a561
        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
a8a561
    fi
a8a561
a8a561
    # Get locale from system
a8a561
    CURRENT_LOCALE=$LC_ALL
a8a561
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
a8a561
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
a8a561
    
a8a561
    # Try without a local variant first, then with a local variant
a8a561
    # So that pt-BR doesn't try to use pt for example
a8a561
    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
a8a561
    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
a8a561
a8a561
    function create_langpack_link() {
a8a561
        local language=$*
a8a561
        local langpack=langpack-${language}@thunderbird.mozilla.org.xpi
a8a561
        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
a8a561
            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
a8a561
            ln -s $MOZ_LANGPACKS_DIR/$langpack \
a8a561
                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
a8a561
            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
a8a561
            return 0
a8a561
        fi
a8a561
        return 1
a8a561
    }
a8a561
a8a561
    create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
a8a561
fi
a8a561
a8a561
exec $MOZ_PROGRAM "$@"