[1237] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
| 3 | # The contents of this file are subject to the Netscape Public |
---|
| 4 | # License Version 1.1 (the "License"); you may not use this file |
---|
| 5 | # except in compliance with the License. You may obtain a copy of |
---|
| 6 | # the License at http://www.mozilla.org/NPL/ |
---|
| 7 | # |
---|
| 8 | # Software distributed under the License is distributed on an "AS |
---|
| 9 | # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
---|
| 10 | # implied. See the License for the specific language governing |
---|
| 11 | # rights and limitations under the License. |
---|
| 12 | # |
---|
| 13 | # The Original Code is mozilla.org code. |
---|
| 14 | # |
---|
| 15 | # The Initial Developer of the Original Code is Netscape |
---|
| 16 | # Communications Corporation. Portions created by Netscape are |
---|
| 17 | # Copyright (C) 1998 Netscape Communications Corporation. All |
---|
| 18 | # Rights Reserved. |
---|
| 19 | # |
---|
| 20 | # Contributor(s): |
---|
| 21 | # |
---|
| 22 | |
---|
| 23 | ## |
---|
| 24 | ## Usage: |
---|
| 25 | ## |
---|
[3236] | 26 | ## $ firefox |
---|
[1237] | 27 | ## |
---|
| 28 | ## This script is meant to run a mozilla program from the mozilla |
---|
| 29 | ## rpm installation. |
---|
| 30 | ## |
---|
| 31 | ## The script will setup all the environment voodoo needed to make |
---|
| 32 | ## mozilla work. |
---|
| 33 | |
---|
| 34 | cmdname=`basename $0` |
---|
| 35 | |
---|
| 36 | ## |
---|
| 37 | ## Variables |
---|
| 38 | ## |
---|
| 39 | MOZ_ARCH=$(uname -m) |
---|
| 40 | case $MOZ_ARCH in |
---|
[3236] | 41 | x86_64 | s390x | sparc64) |
---|
[1237] | 42 | MOZ_LIB_DIR="/usr/lib64" |
---|
| 43 | SECONDARY_LIB_DIR="/usr/lib" |
---|
| 44 | ;; |
---|
| 45 | * ) |
---|
| 46 | MOZ_LIB_DIR="/usr/lib" |
---|
| 47 | SECONDARY_LIB_DIR="/usr/lib64" |
---|
| 48 | ;; |
---|
| 49 | esac |
---|
| 50 | |
---|
[4289] | 51 | MOZ_FIREFOX_FILE="firefox" |
---|
[3236] | 52 | |
---|
[5157] | 53 | if [ ! -r $MOZ_LIB_DIR/firefox/$MOZ_FIREFOX_FILE ]; then |
---|
| 54 | if [ ! -r $SECONDARY_LIB_DIR/firefox/$MOZ_FIREFOX_FILE ]; then |
---|
| 55 | echo "Error: $MOZ_LIB_DIR/firefox/$MOZ_FIREFOX_FILE not found" |
---|
[1237] | 56 | if [ -d $SECONDARY_LIB_DIR ]; then |
---|
[5157] | 57 | echo " $SECONDARY_LIB_DIR/firefox/$MOZ_FIREFOX_FILE not found" |
---|
[1237] | 58 | fi |
---|
| 59 | exit 1 |
---|
| 60 | fi |
---|
| 61 | MOZ_LIB_DIR="$SECONDARY_LIB_DIR" |
---|
| 62 | fi |
---|
[5157] | 63 | MOZ_DIST_BIN="$MOZ_LIB_DIR/firefox" |
---|
| 64 | MOZ_XUL_DIR="$MOZ_LIB_DIR/firefox" |
---|
[3236] | 65 | MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks" |
---|
| 66 | MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" |
---|
[4289] | 67 | MOZ_PROGRAM="$MOZ_DIST_BIN/$MOZ_FIREFOX_FILE" |
---|
[3236] | 68 | MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh" |
---|
| 69 | |
---|
[1237] | 70 | ## |
---|
| 71 | ## Set MOZ_GRE_CONF |
---|
| 72 | ## |
---|
| 73 | MOZ_GRE_CONF=/etc/gre.d/gre.conf |
---|
| 74 | if [ "$MOZ_LIB_DIR" == "/usr/lib64" ]; then |
---|
| 75 | MOZ_GRE_CONF=/etc/gre.d/gre64.conf |
---|
| 76 | fi |
---|
| 77 | export MOZ_GRE_CONF |
---|
| 78 | |
---|
| 79 | ## |
---|
| 80 | ## Set MOZILLA_FIVE_HOME |
---|
| 81 | ## |
---|
| 82 | MOZILLA_FIVE_HOME="$MOZ_DIST_BIN" |
---|
| 83 | |
---|
| 84 | export MOZILLA_FIVE_HOME |
---|
| 85 | |
---|
| 86 | ## |
---|
| 87 | ## Select the propper plugin dir |
---|
| 88 | ## Wrapped plug-ins are located in /lib/mozilla/plugins-wrapped |
---|
| 89 | ## |
---|
| 90 | if [ -x "/usr/bin/mozilla-plugin-config" ] |
---|
| 91 | then |
---|
| 92 | MOZ_PLUGIN_DIR="plugins-wrapped" |
---|
| 93 | else |
---|
| 94 | MOZ_PLUGIN_DIR="plugins" |
---|
| 95 | fi |
---|
| 96 | |
---|
| 97 | ## |
---|
| 98 | ## Make sure that we set the plugin path |
---|
| 99 | ## |
---|
| 100 | if [ "$MOZ_PLUGIN_PATH" ] |
---|
| 101 | then |
---|
| 102 | MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR |
---|
| 103 | else |
---|
| 104 | MOZ_PLUGIN_PATH=$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR |
---|
| 105 | fi |
---|
| 106 | export MOZ_PLUGIN_PATH |
---|
| 107 | |
---|
| 108 | ## |
---|
[3236] | 109 | ## Set MOZ_APP_LAUNCHER for gnome-session |
---|
| 110 | ## |
---|
| 111 | export MOZ_APP_LAUNCHER="/usr/bin/firefox" |
---|
| 112 | |
---|
| 113 | ## |
---|
[1237] | 114 | ## If plugins are wrapped, check them |
---|
| 115 | ## |
---|
| 116 | if [ -x "/usr/bin/mozilla-plugin-config" ] |
---|
| 117 | then |
---|
| 118 | /usr/bin/mozilla-plugin-config |
---|
| 119 | fi |
---|
| 120 | |
---|
| 121 | ## |
---|
| 122 | ## Set FONTCONFIG_PATH for Xft/fontconfig |
---|
| 123 | ## |
---|
| 124 | FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft" |
---|
| 125 | export FONTCONFIG_PATH |
---|
| 126 | |
---|
| 127 | ## |
---|
| 128 | ## Set MOZ_DISABLE_PANGO |
---|
| 129 | ## Vine Linux's firefox is build with Pango rendering by default. |
---|
| 130 | ## But Pango rendering cause slower rendering in some pages especially in CJK page. |
---|
| 131 | ## So we disable it by default. |
---|
| 132 | ## |
---|
| 133 | if [ ! "$MOZ_ENABLE_PANGO" == "1" ] |
---|
| 134 | then |
---|
| 135 | MOZ_DISABLE_PANGO=1 |
---|
| 136 | export MOZ_DISABLE_PANGO |
---|
| 137 | fi |
---|
| 138 | |
---|
| 139 | ## |
---|
| 140 | ## firefox with flash on composite enabled X server |
---|
| 141 | ## |
---|
| 142 | XLIB_SKIP_ARGB_VISUALS=1 |
---|
| 143 | export XLIB_SKIP_ARGB_VISUALS |
---|
| 144 | |
---|
| 145 | ## |
---|
| 146 | ## use Pulseaudio on Flash-plugins, if pulseaudio server is available. |
---|
| 147 | ## |
---|
| 148 | if ( /sbin/pidof pulseauido > /dev/null ) |
---|
| 149 | then |
---|
| 150 | FLASH_FORCE_PULSEAUDIO=1 |
---|
| 151 | export FLASH_FORCE_PULSEAUDIO |
---|
| 152 | fi |
---|
| 153 | |
---|
[3236] | 154 | ## |
---|
| 155 | ## Disable the GNOME crash dialog, Moz has it's own |
---|
| 156 | ## |
---|
| 157 | GNOME_DISABLE_CRASH_DIALOG=1 |
---|
| 158 | export GNOME_DISABLE_CRASH_DIALOG |
---|
| 159 | |
---|
[1237] | 160 | # OK, here's where all the real work gets done |
---|
| 161 | |
---|
[3236] | 162 | |
---|
| 163 | ## |
---|
| 164 | ## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1 |
---|
| 165 | ## in your environment before launching Firefox. |
---|
| 166 | ## |
---|
| 167 | # |
---|
| 168 | # MOZ_DISABLE_LANGPACKS=1 |
---|
| 169 | # export MOZ_DISABLE_LANGPACKS |
---|
| 170 | # |
---|
| 171 | |
---|
| 172 | ## |
---|
| 173 | ## Automatically installed langpacks are tracked by .vine-langpack-install |
---|
| 174 | ## config file. |
---|
| 175 | ## |
---|
| 176 | VINE_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.vine-langpack-install" |
---|
| 177 | |
---|
| 178 | # MOZ_DISABLE_LANGPACKS disables language packs completely |
---|
| 179 | MOZILLA_DOWN=0 |
---|
| 180 | if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then |
---|
| 181 | if [ -x $MOZ_XUL_DIR/mozilla-xremote-client ]; then |
---|
| 182 | # Is firefox running? |
---|
| 183 | $MOZ_XUL_DIR/mozilla-xremote-client -a firefox 'ping()' > /dev/null 2>&1 |
---|
| 184 | MOZILLA_DOWN=$? |
---|
| 185 | fi |
---|
[1237] | 186 | fi |
---|
[3236] | 187 | |
---|
| 188 | # Modify language pack configuration only when firefox is not running |
---|
| 189 | # and language packs are not disabled |
---|
| 190 | if [ $MOZILLA_DOWN -ne 0 ]; then |
---|
| 191 | |
---|
| 192 | # Clear already installed langpacks |
---|
| 193 | mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR |
---|
| 194 | if [ -f $VINE_LANGPACK_CONFIG ]; then |
---|
| 195 | rm `cat $VINE_LANGPACK_CONFIG` > /dev/null 2>&1 |
---|
| 196 | rm $VINE_LANGPACK_CONFIG > /dev/null 2>&1 |
---|
| 197 | fi |
---|
| 198 | |
---|
| 199 | # Get locale from system |
---|
| 200 | CURRENT_LOCALE=$LC_ALL |
---|
| 201 | CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES} |
---|
| 202 | CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG} |
---|
| 203 | |
---|
| 204 | # Try without a local variant first, then with a local variant |
---|
| 205 | # So that pt-BR doesn't try to use pt for example |
---|
| 206 | SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"` |
---|
| 207 | MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"` |
---|
| 208 | |
---|
| 209 | MOZARGS="" |
---|
| 210 | |
---|
| 211 | function create_langpack_link() { |
---|
| 212 | local language=$* |
---|
| 213 | local langpack=langpack-${language}@firefox.mozilla.org.xpi |
---|
| 214 | if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then |
---|
| 215 | rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack |
---|
| 216 | ln -s $MOZ_LANGPACKS_DIR/$langpack \ |
---|
| 217 | $MOZ_EXTENSIONS_PROFILE_DIR/$langpack |
---|
| 218 | echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $VINE_LANGPACK_CONFIG |
---|
| 219 | MOZARGS="-UILocale $MOZLOCALE" |
---|
| 220 | return 0 |
---|
| 221 | fi |
---|
| 222 | return 1 |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true |
---|
| 226 | fi |
---|
| 227 | |
---|
[1237] | 228 | # Prepare command line arguments |
---|
| 229 | script_args="" |
---|
| 230 | pass_arg_count=0 |
---|
| 231 | while [ $# -gt $pass_arg_count ] |
---|
| 232 | do |
---|
| 233 | case "$1" in |
---|
| 234 | -g | --debug) |
---|
| 235 | script_args="$script_args -g" |
---|
| 236 | debugging=1 |
---|
| 237 | shift |
---|
| 238 | ;; |
---|
| 239 | -d | --debugger) |
---|
| 240 | if [ $# -gt 1 ]; then |
---|
| 241 | script_args="$script_args -d $2" |
---|
| 242 | shift 2 |
---|
| 243 | else |
---|
| 244 | shift |
---|
| 245 | fi |
---|
| 246 | ;; |
---|
| 247 | *) |
---|
| 248 | # Move the unrecognized argument to the end of the list. |
---|
| 249 | arg="$1" |
---|
| 250 | shift |
---|
| 251 | set -- "$@" "$arg" |
---|
| 252 | pass_arg_count=`expr $pass_arg_count + 1` |
---|
| 253 | ;; |
---|
| 254 | esac |
---|
| 255 | done |
---|
| 256 | |
---|
| 257 | # Run the browser |
---|
| 258 | debugging=0 |
---|
| 259 | if [ $debugging = 1 ] |
---|
| 260 | then |
---|
[3236] | 261 | echo $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@" |
---|
[1237] | 262 | fi |
---|
| 263 | |
---|
[3236] | 264 | exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@" |
---|