7f8e036
#!/bin/bash
36ac449
#
36ac449
# Startup script for the fedora.us Thunderbird RPM
36ac449
# (based on the Mozilla RPM launch script)
36ac449
#
36ac449
86603f8
##
86603f8
## Variables
86603f8
##
86603f8
MOZ_ARCH=$(uname -m)
86603f8
case $MOZ_ARCH in
c73bef2
        x86_64 | s390x | sparc64 )
832da56
                MOZ_LIB_DIR="__PREFIX__/lib64"
832da56
                SECONDARY_LIB_DIR="__PREFIX__/lib"
86603f8
                ;;
86603f8
        * )
832da56
                MOZ_LIB_DIR="__PREFIX__/lib"
832da56
                SECONDARY_LIB_DIR="__PREFIX__/lib64"
86603f8
                ;;
86603f8
esac
86603f8
8514451
if [ ! -x $MOZ_LIB_DIR/thunderbird/thunderbird ]; then
8514451
    if [ ! -x $SECONDARY_LIB_DIR/thunderbird/thunderbird ]; then
8514451
        echo "Error: $MOZ_LIB_DIR/thunderbird/thunderbird not found"
86603f8
        if [ -d $SECONDARY_LIB_DIR ]; then
8514451
            echo "       $SECONDARY_LIB_DIR/thunderbird/thunderbird not found"
86603f8
        fi
86603f8
        exit 1
86603f8
    fi
86603f8
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
ff6676c
fi
ff6676c
8514451
MOZ_DIST_BIN="$MOZ_LIB_DIR/thunderbird"
86603f8
MOZ_PROGRAM="$MOZ_DIST_BIN/thunderbird"
c73bef2
MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
c73bef2
MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}"
5c98220
MOZ_LAUNCHER="$MOZ_DIST_BIN/thunderbird"
36ac449
0d16653
##
e727439
## Set MOZ_ENABLE_PANGO is no longer used because Pango is enabled by default
e727439
## you may use MOZ_DISABLE_PANGO=1 to force disabling of pango
0d16653
##
e727439
#MOZ_DISABLE_PANGO=1
ff6676c
#export MOZ_DISABLE_PANGO
0d16653
8f2926c
##
30298bb
## Set MOZ_APP_LAUNCHER for gnome-session
30298bb
##
832da56
export MOZ_APP_LAUNCHER="__PREFIX__/bin/thunderbird"
30298bb
30298bb
##
8f2926c
## Disable the GNOME crash dialog, Moz has it's own
8f2926c
## 
8f2926c
GNOME_DISABLE_CRASH_DIALOG=1
8f2926c
export GNOME_DISABLE_CRASH_DIALOG
8f2926c
c73bef2
##
f533f64
## Disable the SLICE allocator (rhbz#1014858)
f533f64
##
f533f64
export G_SLICE=always-malloc
f533f64
f533f64
##
eb8931b
## Allow downgrade because during distro upgrade the build time can be
eb8931b
## older in newer version than the previous one.
eb8931b
##
eb8931b
export MOZ_ALLOW_DOWNGRADE=1
eb8931b
eb8931b
##
c73bef2
## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
c73bef2
## in your environment before launching Firefox.
c73bef2
##
c73bef2
#
c73bef2
# MOZ_DISABLE_LANGPACKS=1
c73bef2
# export MOZ_DISABLE_LANGPACKS
c73bef2
#
c73bef2
c73bef2
##
0c083d7
## Use D-Bus remote exclusively when there's Wayland display.
0c083d7
##
0c083d7
if [ "$WAYLAND_DISPLAY" ]; then
0c083d7
  export MOZ_DBUS_REMOTE=1
0c083d7
fi
0c083d7
0c083d7
##
c73bef2
## Automatically installed langpacks are tracked by .fedora-langpack-install
c73bef2
## config file.
c73bef2
##
c73bef2
FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
c73bef2
c73bef2
# MOZ_DISABLE_LANGPACKS disables language packs completelly
c73bef2
MOZILLA_DOWN=0
c73bef2
if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
30e8c99
    pidof thunderbird > /dev/null 2>&1
30e8c99
    MOZILLA_DOWN=$?
c73bef2
fi
c73bef2
c73bef2
# Modify language pack configuration only when thunderbird is not running 
c73bef2
# and language packs are not disabled
c73bef2
if [ $MOZILLA_DOWN -ne 0 ]; then
c73bef2
c73bef2
    # Clear already installed langpacks
c73bef2
    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
c73bef2
    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
c73bef2
        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
c73bef2
        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
58952be
        # remove all empty langpacks dirs while they block installation of langpacks
58952be
        rmdir $MOZ_EXTENSIONS_PROFILE_DIR/lang* > /dev/null 2>&1
c73bef2
    fi
7ff0535
7ff0535
    # Get locale from system
7ff0535
    CURRENT_LOCALE=$LC_ALL
7ff0535
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
7ff0535
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
c73bef2
    
c73bef2
    # Try without a local variant first, then with a local variant
c73bef2
    # So that pt-BR doesn't try to use pt for example
7ff0535
    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
7ff0535
    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
c73bef2
Christopher Aillon 79e360f
    function create_langpack_link() {
Christopher Aillon 79e360f
        local language=$*
203d662
        local langpack=langpack-${language}@thunderbird.mozilla.org.xpi
203d662
        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
Christopher Aillon 79e360f
            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
Christopher Aillon 79e360f
            ln -s $MOZ_LANGPACKS_DIR/$langpack \
Christopher Aillon 79e360f
                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
Christopher Aillon 79e360f
            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
Christopher Aillon 79e360f
            return 0
c73bef2
        fi
Christopher Aillon 79e360f
        return 1
Christopher Aillon 79e360f
    }
Christopher Aillon 79e360f
Christopher Aillon 79e360f
    create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
c73bef2
fi
c73bef2
2e63d72
# BEAST fix (rhbz#1005611)
2e63d72
NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
2e63d72
export NSS_SSL_CBC_RANDOM_IV
2e63d72
4e2c6cf
# Prepare command line arguments
4e2c6cf
script_args=""
4e2c6cf
pass_arg_count=0
4e2c6cf
while [ $# -gt $pass_arg_count ]
4e2c6cf
do
4e2c6cf
  case "$1" in
4e2c6cf
    -g | --debug)
4e2c6cf
      script_args="$script_args -g"
4e2c6cf
      debugging=1
4e2c6cf
      shift
4e2c6cf
      ;;
4e2c6cf
    -d | --debugger)
4e2c6cf
      if [ $# -gt 1 ]; then
4e2c6cf
        script_args="$script_args -d $2"
4e2c6cf
        shift 2
4e2c6cf
      else
4e2c6cf
        shift
4e2c6cf
      fi
4e2c6cf
      ;;
4e2c6cf
    *)
4e2c6cf
      # Move the unrecognized argument to the end of the list.
4e2c6cf
      arg="$1"
4e2c6cf
      shift
4e2c6cf
      set -- "$@" "$arg"
4e2c6cf
      pass_arg_count=`expr $pass_arg_count + 1`
4e2c6cf
      ;;
4e2c6cf
  esac
4e2c6cf
done
4e2c6cf
200befb
# Don't throw "old profile" dialog box.
200befb
export MOZ_ALLOW_DOWNGRADE=1
200befb
5c98220
exec $MOZ_PROGRAM "$@"