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
##
fa5aab6
MOZ_ARCH=$(uname -m)
fa5aab6
case $MOZ_ARCH in
fa5aab6
	x86_64 | ia64 | s390 )
fa5aab6
		MOZ_LIB_DIR="/usr/lib64"
fa5aab6
		SECONDARY_LIB_DIR="/usr/lib"
fa5aab6
		;;
fa5aab6
	* )
fa5aab6
		MOZ_LIB_DIR="/usr/lib"
fa5aab6
		SECONDARY_LIB_DIR="/usr/lib64"
fa5aab6
		;;
fa5aab6
esac
fa5aab6
fa5aab6
if [ ! -x $MOZ_LIB_DIR/firefox-FIREFOX_VERSION/firefox-bin ]; then
fa5aab6
    if [ ! -x $SECONDARY_LIB_DIR/firefox-FIREFOX_VERSION/firefox-bin ]; then
fa5aab6
	echo "Error: $MOZ_LIB_DIR/firefox-FIREFOX_VERSION/firefox-bin not found"
fa5aab6
	if [ -d $SECONDARY_LIB_DIR ]; then
fa5aab6
	    echo "       $SECONDARY_LIB_DIR/firefox-FIREFOX_VERSION/firefox-bin not found"
fa5aab6
	fi
fa5aab6
	exit 1
fa5aab6
    fi
fa5aab6
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
74adc9d
fi
74adc9d
MOZ_DIST_BIN="$MOZ_LIB_DIR/firefox-FIREFOX_VERSION"
89a39c8
MOZ_EXTENSIONS_DIR="$MOZ_DIST_BIN/extensions"
2261537
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
15debc1
##
15debc1
## Select the propper plugin dir
15debc1
## Wrapped plug-ins are located in /lib/mozilla/plugins-wrapped
15debc1
##
9ba2f30
if [ -x "/usr/bin/mozilla-plugin-config" ]
15debc1
then
15debc1
  MOZ_PLUGIN_DIR="plugins-wrapped"
15debc1
else
15debc1
  MOZ_PLUGIN_DIR="plugins"
15debc1
fi
cvsdist cac9c1c
cvsdist cac9c1c
##
536c4ad
## Make sure that we set the plugin path
cvsdist cac9c1c
##
cvsdist cac9c1c
if [ "$MOZ_PLUGIN_PATH" ]
cvsdist cac9c1c
then
15debc1
  MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR
cvsdist cac9c1c
else
15debc1
  MOZ_PLUGIN_PATH=$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR
cvsdist cac9c1c
fi
cvsdist cac9c1c
export MOZ_PLUGIN_PATH
cvsdist cac9c1c
383a808
##
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 
besfahbo 580eb13
## may negatively impact performance on some pages.  To disable the use of
besfahbo 580eb13
## Pango, set MOZ_DISABLE_PANGO=1 in your environment before launching
besfahbo 580eb13
## 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
05a977b
##
05a977b
## If plugins are wrapped, check them
05a977b
##
05a977b
if [ -x "/usr/bin/mozilla-plugin-config" ]
05a977b
then
05a977b
  /usr/bin/mozilla-plugin-config
05a977b
fi
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=
6afc94d
# Try without a local variant first, then with a local variant
6afc94d
# So that pt-BR doesn't try to use pt for example
6afc94d
SHORTMOZLOCALE=`echo $LANG | sed "s|_\([^.]*\).*||g"`
6afc94d
[ -f $MOZ_EXTENSIONS_DIR/langpack-${SHORTMOZLOCALE}@firefox.mozilla.org/chrome/$SHORTMOZLOCALE.jar ] && MOZARGS="-UILocale $SHORTMOZLOCALE"
6afc94d
cvsdist cac9c1c
MOZLOCALE=`echo $LANG | sed "s|_\([^.]*\).*|-\1|g"`
6afc94d
[ -f $MOZ_EXTENSIONS_DIR/langpack-${MOZLOCALE}@firefox.mozilla.org/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+"$@"}