[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" |
---|
[3236] | 64 | MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks" |
---|
| 65 | MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" |
---|
[4289] | 66 | MOZ_PROGRAM="$MOZ_DIST_BIN/$MOZ_FIREFOX_FILE" |
---|
[3236] | 67 | MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh" |
---|
[11974] | 68 | |
---|
[1237] | 69 | ## |
---|
| 70 | ## Set MOZ_GRE_CONF |
---|
| 71 | ## |
---|
| 72 | MOZ_GRE_CONF=/etc/gre.d/gre.conf |
---|
| 73 | if [ "$MOZ_LIB_DIR" == "/usr/lib64" ]; then |
---|
| 74 | MOZ_GRE_CONF=/etc/gre.d/gre64.conf |
---|
| 75 | fi |
---|
| 76 | export MOZ_GRE_CONF |
---|
| 77 | |
---|
| 78 | ## |
---|
| 79 | ## Set MOZILLA_FIVE_HOME |
---|
| 80 | ## |
---|
| 81 | MOZILLA_FIVE_HOME="$MOZ_DIST_BIN" |
---|
| 82 | |
---|
| 83 | export MOZILLA_FIVE_HOME |
---|
| 84 | |
---|
| 85 | ## |
---|
| 86 | ## Make sure that we set the plugin path |
---|
| 87 | ## |
---|
[11974] | 88 | MOZ_PLUGIN_DIR="plugins" |
---|
| 89 | |
---|
[1237] | 90 | if [ "$MOZ_PLUGIN_PATH" ] |
---|
| 91 | then |
---|
| 92 | MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR |
---|
| 93 | else |
---|
| 94 | MOZ_PLUGIN_PATH=$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR |
---|
| 95 | fi |
---|
| 96 | export MOZ_PLUGIN_PATH |
---|
| 97 | |
---|
| 98 | ## |
---|
[3236] | 99 | ## Set MOZ_APP_LAUNCHER for gnome-session |
---|
| 100 | ## |
---|
| 101 | export MOZ_APP_LAUNCHER="/usr/bin/firefox" |
---|
| 102 | |
---|
| 103 | ## |
---|
[1237] | 104 | ## Set FONTCONFIG_PATH for Xft/fontconfig |
---|
| 105 | ## |
---|
| 106 | FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft" |
---|
| 107 | export FONTCONFIG_PATH |
---|
| 108 | |
---|
| 109 | ## |
---|
| 110 | ## Set MOZ_DISABLE_PANGO |
---|
| 111 | ## Vine Linux's firefox is build with Pango rendering by default. |
---|
| 112 | ## But Pango rendering cause slower rendering in some pages especially in CJK page. |
---|
| 113 | ## So we disable it by default. |
---|
| 114 | ## |
---|
| 115 | if [ ! "$MOZ_ENABLE_PANGO" == "1" ] |
---|
| 116 | then |
---|
| 117 | MOZ_DISABLE_PANGO=1 |
---|
| 118 | export MOZ_DISABLE_PANGO |
---|
| 119 | fi |
---|
| 120 | |
---|
| 121 | ## |
---|
| 122 | ## firefox with flash on composite enabled X server |
---|
| 123 | ## |
---|
| 124 | XLIB_SKIP_ARGB_VISUALS=1 |
---|
| 125 | export XLIB_SKIP_ARGB_VISUALS |
---|
| 126 | |
---|
| 127 | ## |
---|
| 128 | ## use Pulseaudio on Flash-plugins, if pulseaudio server is available. |
---|
| 129 | ## |
---|
| 130 | if ( /sbin/pidof pulseauido > /dev/null ) |
---|
| 131 | then |
---|
| 132 | FLASH_FORCE_PULSEAUDIO=1 |
---|
| 133 | export FLASH_FORCE_PULSEAUDIO |
---|
| 134 | fi |
---|
| 135 | |
---|
[3236] | 136 | ## |
---|
| 137 | ## Disable the GNOME crash dialog, Moz has it's own |
---|
| 138 | ## |
---|
| 139 | GNOME_DISABLE_CRASH_DIALOG=1 |
---|
| 140 | export GNOME_DISABLE_CRASH_DIALOG |
---|
| 141 | |
---|
[1237] | 142 | # OK, here's where all the real work gets done |
---|
| 143 | |
---|
[3236] | 144 | |
---|
| 145 | ## |
---|
| 146 | ## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1 |
---|
| 147 | ## in your environment before launching Firefox. |
---|
| 148 | ## |
---|
| 149 | # |
---|
| 150 | # MOZ_DISABLE_LANGPACKS=1 |
---|
| 151 | # export MOZ_DISABLE_LANGPACKS |
---|
| 152 | # |
---|
| 153 | |
---|
| 154 | ## |
---|
| 155 | ## Automatically installed langpacks are tracked by .vine-langpack-install |
---|
| 156 | ## config file. |
---|
| 157 | ## |
---|
| 158 | VINE_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.vine-langpack-install" |
---|
| 159 | |
---|
[11974] | 160 | # Since Firefox 60 the installation of individual langpack cannot be done by |
---|
| 161 | # copying xpi file to the home directory, because the langpack is loaded |
---|
| 162 | # as to the available languages after the language has been decided and |
---|
| 163 | # for the first run it won't be in language according to the locale. |
---|
| 164 | # |
---|
| 165 | # The current workaround is to put all langpacks to the location |
---|
| 166 | # for system wide extensions. So we set MOZ_DISABLE_LANGPACKS=1 for this moment |
---|
| 167 | export MOZ_DISABLE_LANGPACKS=1 |
---|
[3236] | 168 | # MOZ_DISABLE_LANGPACKS disables language packs completely |
---|
| 169 | MOZILLA_DOWN=0 |
---|
| 170 | if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then |
---|
[11974] | 171 | if [ -x $MOZ_DIST_BIN/$MOZ_FIREFOX_FILE ]; then |
---|
| 172 | # Is firefox running? |
---|
| 173 | /usr/bin/pidof firefox > /dev/null 2>&1 |
---|
| 174 | MOZILLA_DOWN=$? |
---|
| 175 | fi |
---|
[1237] | 176 | fi |
---|
[3236] | 177 | |
---|
| 178 | # Modify language pack configuration only when firefox is not running |
---|
| 179 | # and language packs are not disabled |
---|
| 180 | if [ $MOZILLA_DOWN -ne 0 ]; then |
---|
| 181 | |
---|
| 182 | # Clear already installed langpacks |
---|
| 183 | mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR |
---|
| 184 | if [ -f $VINE_LANGPACK_CONFIG ]; then |
---|
| 185 | rm `cat $VINE_LANGPACK_CONFIG` > /dev/null 2>&1 |
---|
| 186 | rm $VINE_LANGPACK_CONFIG > /dev/null 2>&1 |
---|
[11974] | 187 | # remove all empty langpacks dirs while they block installation of langpacks |
---|
| 188 | rmdir $MOZ_EXTENSIONS_PROFILE_DIR/langpack* > /dev/null 2>&1 |
---|
[3236] | 189 | fi |
---|
| 190 | |
---|
| 191 | # Get locale from system |
---|
| 192 | CURRENT_LOCALE=$LC_ALL |
---|
| 193 | CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES} |
---|
| 194 | CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG} |
---|
[11974] | 195 | |
---|
| 196 | # Try with a local variant first, then without a local variant |
---|
[3236] | 197 | SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"` |
---|
| 198 | MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"` |
---|
| 199 | |
---|
| 200 | function create_langpack_link() { |
---|
| 201 | local language=$* |
---|
| 202 | local langpack=langpack-${language}@firefox.mozilla.org.xpi |
---|
| 203 | if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then |
---|
| 204 | rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack |
---|
[11974] | 205 | # If the target file is a symlink (the fallback langpack), |
---|
| 206 | # install the original file instead of the fallback one |
---|
| 207 | if [ -h $MOZ_LANGPACKS_DIR/$langpack ]; then |
---|
| 208 | langpack=`readlink $MOZ_LANGPACKS_DIR/$langpack` |
---|
| 209 | fi |
---|
[3236] | 210 | ln -s $MOZ_LANGPACKS_DIR/$langpack \ |
---|
| 211 | $MOZ_EXTENSIONS_PROFILE_DIR/$langpack |
---|
| 212 | echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $VINE_LANGPACK_CONFIG |
---|
| 213 | return 0 |
---|
| 214 | fi |
---|
| 215 | return 1 |
---|
| 216 | } |
---|
| 217 | |
---|
[11974] | 218 | create_langpack_link $MOZLOCALE || create_langpack_link $SHORTMOZLOCALE || true |
---|
[3236] | 219 | fi |
---|
| 220 | |
---|
[11974] | 221 | # BEAST fix (rhbz#1005611) |
---|
| 222 | NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1} |
---|
| 223 | export NSS_SSL_CBC_RANDOM_IV |
---|
| 224 | |
---|
[1237] | 225 | # Prepare command line arguments |
---|
| 226 | script_args="" |
---|
| 227 | pass_arg_count=0 |
---|
| 228 | while [ $# -gt $pass_arg_count ] |
---|
| 229 | do |
---|
| 230 | case "$1" in |
---|
| 231 | -g | --debug) |
---|
| 232 | script_args="$script_args -g" |
---|
| 233 | debugging=1 |
---|
| 234 | shift |
---|
| 235 | ;; |
---|
| 236 | -d | --debugger) |
---|
| 237 | if [ $# -gt 1 ]; then |
---|
| 238 | script_args="$script_args -d $2" |
---|
| 239 | shift 2 |
---|
| 240 | else |
---|
| 241 | shift |
---|
| 242 | fi |
---|
| 243 | ;; |
---|
| 244 | *) |
---|
| 245 | # Move the unrecognized argument to the end of the list. |
---|
| 246 | arg="$1" |
---|
| 247 | shift |
---|
| 248 | set -- "$@" "$arg" |
---|
| 249 | pass_arg_count=`expr $pass_arg_count + 1` |
---|
| 250 | ;; |
---|
| 251 | esac |
---|
| 252 | done |
---|
| 253 | |
---|
| 254 | # Run the browser |
---|
| 255 | debugging=0 |
---|
| 256 | if [ $debugging = 1 ] |
---|
| 257 | then |
---|
[3236] | 258 | echo $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@" |
---|
[1237] | 259 | fi |
---|
| 260 | |
---|
[3236] | 261 | exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@" |
---|