kalev / rpms / firefox

Forked from rpms/firefox 5 years ago
Clone
cvsdist cac9c1c
#!/bin/sh
cvsdist cac9c1c
#
cvsdist cac9c1c
# The contents of this file are subject to the Netscape Public
cvsdist cac9c1c
# License Version 1.1 (the "License"); you may not use this file
cvsdist cac9c1c
# except in compliance with the License. You may obtain a copy of
cvsdist cac9c1c
# the License at http://www.mozilla.org/NPL/
cvsdist cac9c1c
#
cvsdist cac9c1c
# Software distributed under the License is distributed on an "AS
cvsdist cac9c1c
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
cvsdist cac9c1c
# implied. See the License for the specific language governing
cvsdist cac9c1c
# rights and limitations under the License.
cvsdist cac9c1c
#
cvsdist cac9c1c
# The Original Code is mozilla.org code.
cvsdist cac9c1c
#
cvsdist cac9c1c
# The Initial Developer of the Original Code is Netscape
cvsdist cac9c1c
# Communications Corporation.  Portions created by Netscape are
cvsdist cac9c1c
# Copyright (C) 1998 Netscape Communications Corporation. All
cvsdist cac9c1c
# Rights Reserved.
cvsdist cac9c1c
#
cvsdist cac9c1c
# Contributor(s): 
cvsdist cac9c1c
#
cvsdist cac9c1c
cvsdist cac9c1c
## 
cvsdist cac9c1c
## Usage:
cvsdist cac9c1c
##
cvsdist cac9c1c
## $ mozilla
cvsdist cac9c1c
##
cvsdist cac9c1c
## This script is meant to run a mozilla program from the mozilla
cvsdist cac9c1c
## rpm installation.
cvsdist cac9c1c
##
cvsdist cac9c1c
## The script will setup all the environment voodoo needed to make
cvsdist cac9c1c
## mozilla work.
cvsdist cac9c1c
cvsdist cac9c1c
cmdname=`basename $0`
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Variables
cvsdist cac9c1c
##
74adc9d
MOZ_LIB_DIR="/usr/lib"
74adc9d
if [ -x "/usr/lib64/firefox-FIREFOX_VERSION/firefox-bin" ]
74adc9d
then
74adc9d
  MOZ_LIB_DIR="/usr/lib64"
74adc9d
fi
74adc9d
MOZ_DIST_BIN="$MOZ_LIB_DIR/firefox-FIREFOX_VERSION"
cvsdist cac9c1c
MOZ_PROGRAM="$MOZ_DIST_BIN/firefox"
cvsdist cac9c1c
MOZ_CLIENT_PROGRAM="$MOZ_DIST_BIN/mozilla-xremote-client"
cvsdist cac9c1c
MOZ_CLIENT_PROGRAM_PARAM="-a firefox"
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Set MOZILLA_FIVE_HOME
cvsdist cac9c1c
##
cvsdist cac9c1c
MOZILLA_FIVE_HOME="$MOZ_DIST_BIN"
cvsdist cac9c1c
cvsdist cac9c1c
export MOZILLA_FIVE_HOME
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Set LD_LIBRARY_PATH
cvsdist cac9c1c
##
cvsdist cac9c1c
if [ "$LD_LIBRARY_PATH" ]
cvsdist cac9c1c
then
cvsdist cac9c1c
  LD_LIBRARY_PATH=$MOZ_DIST_BIN:$MOZ_DIST_BIN/plugins:$LD_LIBRARY_PATH
cvsdist cac9c1c
else
084a3d1
  LD_LIBRARY_PATH=$MOZ_DIST_BIN:$MOZ_DIST_BIN/plugins
cvsdist cac9c1c
fi
cvsdist cac9c1c
cvsdist cac9c1c
export LD_LIBRARY_PATH
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Make sure that we set the plugin path for backwards compatibility
cvsdist cac9c1c
##
cvsdist cac9c1c
if [ "$MOZ_PLUGIN_PATH" ]
cvsdist cac9c1c
then
74adc9d
  MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:$MOZ_LIB_DIR/mozilla/plugins:$MOZ_DIST_BIN/plugins
cvsdist cac9c1c
else
74adc9d
  MOZ_PLUGIN_PATH=$MOZ_LIB_DIR/mozilla/plugins:$MOZ_DIST_BIN/plugins
cvsdist cac9c1c
fi
cvsdist cac9c1c
export MOZ_PLUGIN_PATH
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Set FONTCONFIG_PATH for Xft/fontconfig
cvsdist cac9c1c
##
cvsdist cac9c1c
FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft"
cvsdist cac9c1c
export FONTCONFIG_PATH
cvsdist cac9c1c
2ca6e87
##
da97c6e
## In order to better support certain scripts (such as Indic and some CJK 
da97c6e
## scripts), Fedora builds its Firefox, with permission from the Mozilla 
da97c6e
## Corporation, with the Pango system as its text renderer.  This change 
da97c6e
## is known to break rendering of MathML, and may negatively impact 
da97c6e
## performance on some pages.  To disable the use of Pango, set 
da97c6e
## MOZ_DISABLE_PANGO=1 in your environment before launching Firefox.
2ca6e87
##
da97c6e
#
da97c6e
# MOZ_DISABLE_PANGO=1
da97c6e
# export MOZ_DISABLE_PANGO
da97c6e
#
f381d84
cvsdist cac9c1c
function check_running() {
cvsdist cac9c1c
    $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM 'ping()' 2>/dev/null >/dev/null
cvsdist cac9c1c
    RETURN_VAL=$?
cvsdist cac9c1c
    if [ "$RETURN_VAL" -eq "2" ]; then
cvsdist cac9c1c
      echo 0
cvsdist cac9c1c
      return 0
cvsdist cac9c1c
    else
cvsdist cac9c1c
      echo 1
cvsdist cac9c1c
      return 1
cvsdist cac9c1c
    fi
cvsdist cac9c1c
}
cvsdist cac9c1c
cvsdist cac9c1c
function open_mail() {
cvsdist cac9c1c
    if [ "${ALREADY_RUNNING}" -eq "1" ]; then
cvsdist cac9c1c
      exec $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM 'xfeDoCommand(openInbox)' \
cvsdist cac9c1c
        2>/dev/null >/dev/null
cvsdist cac9c1c
    else
cvsdist cac9c1c
      exec $MOZ_PROGRAM $*
cvsdist cac9c1c
    fi
cvsdist cac9c1c
}
cvsdist cac9c1c
cvsdist cac9c1c
function open_compose() {
cvsdist cac9c1c
    if [ "${ALREADY_RUNNING}" -eq "1" ]; then
cvsdist cac9c1c
      exec $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM 'xfeDoCommand(composeMessage)' \
cvsdist cac9c1c
        2>/dev/null >/dev/null
cvsdist cac9c1c
    else
cvsdist cac9c1c
      exec $MOZ_PROGRAM $*
cvsdist cac9c1c
    fi
cvsdist cac9c1c
}
cvsdist cac9c1c
cvsdist cac9c1c
# OK, here's where all the real work gets done
cvsdist cac9c1c
cvsdist cac9c1c
# check to see if there's an already running instance or not
cvsdist cac9c1c
ALREADY_RUNNING=`check_running`
cvsdist cac9c1c
cvsdist cac9c1c
# If there is no command line argument at all then try to open a new
cvsdist cac9c1c
# window in an already running instance.
cvsdist cac9c1c
if [ "${ALREADY_RUNNING}" -eq "1" ] && [ -z "$1" ]; then
cvsdist cac9c1c
  exec $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM "xfeDoCommand(openBrowser)" 2>/dev/null>/dev/null
cvsdist cac9c1c
fi
cvsdist cac9c1c
cvsdist cac9c1c
# check system locale
cvsdist cac9c1c
MOZARGS=
cvsdist cac9c1c
MOZLOCALE=`echo $LANG | sed "s|_\([^.]*\).*|-\1|g"`
cvsdist cac9c1c
[ -f $MOZILLA_FIVE_HOME/chrome/$MOZLOCALE.jar ] && MOZARGS="-UILocale $MOZLOCALE"
cvsdist cac9c1c
cvsdist cac9c1c
cvsdist cac9c1c
# if there's no command line argument and there's not a running
cvsdist cac9c1c
# instance then just fire up a new copy of the browser
cvsdist cac9c1c
if [ -z "$1" ]; then
cvsdist cac9c1c
  exec $MOZ_PROGRAM $MOZARGS 2>/dev/null >/dev/null
cvsdist cac9c1c
fi
cvsdist cac9c1c
cvsdist cac9c1c
unset RETURN_VAL
cvsdist cac9c1c
cvsdist cac9c1c
# If there's a command line argument but it doesn't begin with a -
cvsdist cac9c1c
# it's probably a url.  Try to send it to a running instance.
cvsdist cac9c1c
cvsdist cac9c1c
USE_EXIST=0
cvsdist cac9c1c
opt="$1"
cvsdist cac9c1c
case "$opt" in
cvsdist cac9c1c
  -mail)
cvsdist cac9c1c
      open_mail ${1+"$@"}
cvsdist cac9c1c
      ;;
cvsdist cac9c1c
  -compose)
cvsdist cac9c1c
      open_compose ${1+"$@"}
cvsdist cac9c1c
      ;;
cvsdist cac9c1c
  -*) ;;
cvsdist cac9c1c
  *) USE_EXIST=1 ;;
cvsdist cac9c1c
esac
cvsdist cac9c1c
cvsdist cac9c1c
if [ "${USE_EXIST}" -eq "1" ] && [ "${ALREADY_RUNNING}" -eq "1" ]; then
56ab92b
  opt=`echo -n "$opt" | sed -e 's/,/%2c/g' -e 's/ /%20/g'`
cvsdist cac9c1c
  # check to make sure that the command contains at least a :/ in it.
cvsdist cac9c1c
  echo $opt | grep -e ':/' 2>/dev/null > /dev/null
cvsdist cac9c1c
  RETURN_VAL=$?
cvsdist cac9c1c
  if [ "$RETURN_VAL" -eq "1" ]; then
cvsdist cac9c1c
    # if it doesn't begin with a '/' and it exists when the pwd is
cvsdist cac9c1c
    # prepended to it then append the full path
cvsdist cac9c1c
    echo $opt | grep -e '^/' 2>/dev/null > /dev/null
2c9ee4d
    if [ "${RETURN_VAL}" -ne "0" ] && [ -e "`pwd`/$opt" ]; then
cvsdist cac9c1c
      opt="`pwd`/$opt"
cvsdist cac9c1c
    fi
cvsdist cac9c1c
    exec $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM "openurl($opt)" 2>/dev/null >/dev/null
cvsdist cac9c1c
  fi
cvsdist cac9c1c
  # just pass it off if it looks like a url
807f6a8
  exec $MOZ_CLIENT_PROGRAM $MOZ_CLIENT_PROGRAM_PARAM "openurl($opt)" 2>/dev/null >/dev/null
cvsdist cac9c1c
fi
cvsdist cac9c1c
cvsdist cac9c1c
exec $MOZ_PROGRAM $MOZARGS ${1+"$@"}