firefox.vine.sh.in 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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_XUL_DIR="$MOZ_LIB_DIR/firefox"
  60. MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
  61. MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  62. MOZ_PROGRAM="$MOZ_DIST_BIN/$MOZ_FIREFOX_FILE"
  63. MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh"
  64. ##
  65. ## Set MOZ_GRE_CONF
  66. ##
  67. MOZ_GRE_CONF=/etc/gre.d/gre.conf
  68. if [ "$MOZ_LIB_DIR" == "/usr/lib64" ]; then
  69. MOZ_GRE_CONF=/etc/gre.d/gre64.conf
  70. fi
  71. export MOZ_GRE_CONF
  72. ##
  73. ## Set MOZILLA_FIVE_HOME
  74. ##
  75. MOZILLA_FIVE_HOME="$MOZ_DIST_BIN"
  76. export MOZILLA_FIVE_HOME
  77. ##
  78. ## Select the propper plugin dir
  79. ## Wrapped plug-ins are located in /lib/mozilla/plugins-wrapped
  80. ##
  81. if [ -x "/usr/bin/mozilla-plugin-config" ]
  82. then
  83. MOZ_PLUGIN_DIR="plugins-wrapped"
  84. else
  85. MOZ_PLUGIN_DIR="plugins"
  86. fi
  87. ##
  88. ## Make sure that we set the plugin path
  89. ##
  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. ## Set MOZ_APP_LAUNCHER for gnome-session
  99. ##
  100. export MOZ_APP_LAUNCHER="/usr/bin/firefox"
  101. ##
  102. ## If plugins are wrapped, check them
  103. ##
  104. if [ -x "/usr/bin/mozilla-plugin-config" ]
  105. then
  106. /usr/bin/mozilla-plugin-config
  107. fi
  108. ##
  109. ## Set FONTCONFIG_PATH for Xft/fontconfig
  110. ##
  111. FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft"
  112. export FONTCONFIG_PATH
  113. ##
  114. ## Set MOZ_DISABLE_PANGO
  115. ## Vine Linux's firefox is build with Pango rendering by default.
  116. ## But Pango rendering cause slower rendering in some pages especially in CJK page.
  117. ## So we disable it by default.
  118. ##
  119. if [ ! "$MOZ_ENABLE_PANGO" == "1" ]
  120. then
  121. MOZ_DISABLE_PANGO=1
  122. export MOZ_DISABLE_PANGO
  123. fi
  124. ##
  125. ## firefox with flash on composite enabled X server
  126. ##
  127. XLIB_SKIP_ARGB_VISUALS=1
  128. export XLIB_SKIP_ARGB_VISUALS
  129. ##
  130. ## use Pulseaudio on Flash-plugins, if pulseaudio server is available.
  131. ##
  132. if ( /sbin/pidof pulseauido > /dev/null )
  133. then
  134. FLASH_FORCE_PULSEAUDIO=1
  135. export FLASH_FORCE_PULSEAUDIO
  136. fi
  137. ##
  138. ## Disable the GNOME crash dialog, Moz has it's own
  139. ##
  140. GNOME_DISABLE_CRASH_DIALOG=1
  141. export GNOME_DISABLE_CRASH_DIALOG
  142. # OK, here's where all the real work gets done
  143. ##
  144. ## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
  145. ## in your environment before launching Firefox.
  146. ##
  147. #
  148. # MOZ_DISABLE_LANGPACKS=1
  149. # export MOZ_DISABLE_LANGPACKS
  150. #
  151. ##
  152. ## Automatically installed langpacks are tracked by .vine-langpack-install
  153. ## config file.
  154. ##
  155. VINE_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.vine-langpack-install"
  156. # MOZ_DISABLE_LANGPACKS disables language packs completely
  157. MOZILLA_DOWN=0
  158. if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
  159. # Is firefox running?
  160. exec ps ax | grep $MOZ_PROGRAM | grep -v grep > /dev/null 2>&1
  161. MOZILLA_DOWN=$?
  162. fi
  163. # Modify language pack configuration only when firefox is not running
  164. # and language packs are not disabled
  165. if [ $MOZILLA_DOWN -ne 0 ]; then
  166. # Clear already installed langpacks
  167. mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
  168. if [ -f $VINE_LANGPACK_CONFIG ]; then
  169. rm `cat $VINE_LANGPACK_CONFIG` > /dev/null 2>&1
  170. rm $VINE_LANGPACK_CONFIG > /dev/null 2>&1
  171. fi
  172. # Get locale from system
  173. CURRENT_LOCALE=$LC_ALL
  174. CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
  175. CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
  176. # Try without a local variant first, then with a local variant
  177. # So that pt-BR doesn't try to use pt for example
  178. SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
  179. MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
  180. MOZARGS=""
  181. function create_langpack_link() {
  182. local language=$*
  183. local langpack=langpack-${language}@firefox.mozilla.org.xpi
  184. if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
  185. rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
  186. ln -s $MOZ_LANGPACKS_DIR/$langpack \
  187. $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
  188. echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $VINE_LANGPACK_CONFIG
  189. MOZARGS="-UILocale $MOZLOCALE"
  190. return 0
  191. fi
  192. return 1
  193. }
  194. create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
  195. fi
  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 "$@"