firefox.vine.sh.in 7.0 KB

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