e75128
#!/bin/bash
e75128
#
e75128
# Startup script for the fedora.us Thunderbird RPM
e75128
# (based on the Mozilla RPM launch script)
e75128
#
e75128
e75128
##
e75128
## Variables
e75128
##
e75128
MOZ_ARCH=$(uname -m)
e75128
case $MOZ_ARCH in
e75128
        x86_64 | s390x | sparc64 )
e75128
                MOZ_LIB_DIR="/usr/lib64"
e75128
                SECONDARY_LIB_DIR="/usr/lib"
e75128
                ;;
e75128
        * )
e75128
                MOZ_LIB_DIR="/usr/lib"
e75128
                SECONDARY_LIB_DIR="/usr/lib64"
e75128
                ;;
e75128
esac
e75128
e75128
if [ ! -x $MOZ_LIB_DIR/thunderbird/thunderbird ]; then
e75128
    if [ ! -x $SECONDARY_LIB_DIR/thunderbird/thunderbird ]; then
e75128
        echo "Error: $MOZ_LIB_DIR/thunderbird/thunderbird not found"
e75128
        if [ -d $SECONDARY_LIB_DIR ]; then
e75128
            echo "       $SECONDARY_LIB_DIR/thunderbird/thunderbird not found"
e75128
        fi
e75128
        exit 1
e75128
    fi
e75128
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
e75128
fi
e75128
e75128
MOZ_DIST_BIN="$MOZ_LIB_DIR/thunderbird"
e75128
MOZ_PROGRAM="$MOZ_DIST_BIN/thunderbird"
e75128
MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
e75128
MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}"
e75128
MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh"
e75128
e75128
##
e75128
## Set MOZ_ENABLE_PANGO is no longer used because Pango is enabled by default
e75128
## you may use MOZ_DISABLE_PANGO=1 to force disabling of pango
e75128
##
e75128
#MOZ_DISABLE_PANGO=1
e75128
#export MOZ_DISABLE_PANGO
e75128
e75128
##
e75128
## Set MOZ_APP_LAUNCHER for gnome-session
e75128
##
e75128
export MOZ_APP_LAUNCHER="/usr/bin/thunderbird"
e75128
e75128
##
e75128
## Disable the GNOME crash dialog, Moz has it's own
e75128
## 
e75128
GNOME_DISABLE_CRASH_DIALOG=1
e75128
export GNOME_DISABLE_CRASH_DIALOG
e75128
e75128
##
e75128
## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
e75128
## in your environment before launching Firefox.
e75128
##
e75128
#
e75128
# MOZ_DISABLE_LANGPACKS=1
e75128
# export MOZ_DISABLE_LANGPACKS
e75128
#
e75128
e75128
##
e75128
## Automatically installed langpacks are tracked by .fedora-langpack-install
e75128
## config file.
e75128
##
e75128
FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
e75128
e75128
# MOZ_DISABLE_LANGPACKS disables language packs completelly
e75128
MOZILLA_DOWN=0
e75128
if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
e75128
    if [ -x $MOZ_DIST_BIN/mozilla-xremote-client ]; then
e75128
        # Is thunderbird running?
e75128
        $MOZ_DIST_BIN/mozilla-xremote-client -a thunderbird 'ping()' > /dev/null 2>&1
e75128
        MOZILLA_DOWN=$?
e75128
    fi
e75128
fi
e75128
e75128
# Modify language pack configuration only when thunderbird is not running 
e75128
# and language packs are not disabled
e75128
if [ $MOZILLA_DOWN -ne 0 ]; then
e75128
e75128
    # Clear already installed langpacks
e75128
    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
e75128
    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
e75128
        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
e75128
        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
e75128
        # remove all empty langpacks dirs while they block installation of langpacks
e75128
        rmdir $MOZ_EXTENSIONS_PROFILE_DIR/lang* > /dev/null 2>&1
e75128
    fi
e75128
e75128
    # Get locale from system
e75128
    CURRENT_LOCALE=$LC_ALL
e75128
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
e75128
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
e75128
    
e75128
    # Try without a local variant first, then with a local variant
e75128
    # So that pt-BR doesn't try to use pt for example
e75128
    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
e75128
    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
e75128
e75128
    function create_langpack_link() {
e75128
        local language=$*
e75128
        local langpack=langpack-${language}@thunderbird.mozilla.org.xpi
e75128
        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
e75128
            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
e75128
            ln -s $MOZ_LANGPACKS_DIR/$langpack \
e75128
                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
e75128
            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
e75128
            return 0
e75128
        fi
e75128
        return 1
e75128
    }
e75128
e75128
    create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
e75128
fi
e75128
e75128
# BEAST fix (rhbz#1005611)
e75128
NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
e75128
export NSS_SSL_CBC_RANDOM_IV
e75128
e75128
# Prepare command line arguments
e75128
script_args=""
e75128
pass_arg_count=0
e75128
while [ $# -gt $pass_arg_count ]
e75128
do
e75128
  case "$1" in
e75128
    -g | --debug)
e75128
      script_args="$script_args -g"
e75128
      debugging=1
e75128
      shift
e75128
      ;;
e75128
    -d | --debugger)
e75128
      if [ $# -gt 1 ]; then
e75128
        script_args="$script_args -d $2"
e75128
        shift 2
e75128
      else
e75128
        shift
e75128
      fi
e75128
      ;;
e75128
    *)
e75128
      # Move the unrecognized argument to the end of the list.
e75128
      arg="$1"
e75128
      shift
e75128
      set -- "$@" "$arg"
e75128
      pass_arg_count=`expr $pass_arg_count + 1`
e75128
      ;;
e75128
  esac
e75128
done
e75128
e75128
exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM "$@"