firefox.vine.sh.in 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. if [ -x $MOZ_XUL_DIR/mozilla-xremote-client ]; then
  160. # Is firefox running?
  161. $MOZ_XUL_DIR/mozilla-xremote-client -a firefox 'ping()' > /dev/null 2>&1
  162. MOZILLA_DOWN=$?
  163. fi
  164. fi
  165. # Modify language pack configuration only when firefox is not running
  166. # and language packs are not disabled
  167. if [ $MOZILLA_DOWN -ne 0 ]; then
  168. # Clear already installed langpacks
  169. mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
  170. if [ -f $VINE_LANGPACK_CONFIG ]; then
  171. rm `cat $VINE_LANGPACK_CONFIG` > /dev/null 2>&1
  172. rm $VINE_LANGPACK_CONFIG > /dev/null 2>&1
  173. fi
  174. # Get locale from system
  175. CURRENT_LOCALE=$LC_ALL
  176. CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
  177. CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
  178. # Try without a local variant first, then with a local variant
  179. # So that pt-BR doesn't try to use pt for example
  180. SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g"`
  181. MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g"`
  182. MOZARGS=""
  183. function create_langpack_link() {
  184. local language=$*
  185. local langpack=langpack-${language}@firefox.mozilla.org.xpi
  186. if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
  187. rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
  188. ln -s $MOZ_LANGPACKS_DIR/$langpack \
  189. $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
  190. echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $VINE_LANGPACK_CONFIG
  191. MOZARGS="-UILocale $MOZLOCALE"
  192. return 0
  193. fi
  194. return 1
  195. }
  196. create_langpack_link $SHORTMOZLOCALE || create_langpack_link $MOZLOCALE || true
  197. fi
  198. # Prepare command line arguments
  199. script_args=""
  200. pass_arg_count=0
  201. while [ $# -gt $pass_arg_count ]
  202. do
  203. case "$1" in
  204. -g | --debug)
  205. script_args="$script_args -g"
  206. debugging=1
  207. shift
  208. ;;
  209. -d | --debugger)
  210. if [ $# -gt 1 ]; then
  211. script_args="$script_args -d $2"
  212. shift 2
  213. else
  214. shift
  215. fi
  216. ;;
  217. *)
  218. # Move the unrecognized argument to the end of the list.
  219. arg="$1"
  220. shift
  221. set -- "$@" "$arg"
  222. pass_arg_count=`expr $pass_arg_count + 1`
  223. ;;
  224. esac
  225. done
  226. # Run the browser
  227. debugging=0
  228. if [ $debugging = 1 ]
  229. then
  230. echo $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@"
  231. fi
  232. exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM $MOZARGS "$@"