home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / firefox / firefox < prev    next >
Encoding:
Text File  |  2006-08-18  |  8.3 KB  |  302 lines

  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. ## For silly people running firefox through sudo
  25. ##
  26. if [ "${SUDO_USER}" ] && [ "${SUDO_USER}" != "${USER}" ]; then
  27.     SUDO_HOME=`getent passwd ${SUDO_USER} | cut -f6 -d:`
  28.     if [ "${SUDO_HOME}" = "${HOME}" ]; then
  29.         echo "You should really not run firefox through sudo WITHOUT the -H option." >&2
  30.         echo "Anyway, I'll do as if you did use the -H option." >&2
  31.         HOME=`getent passwd ${USER} | cut -f6 -d:`
  32.         if [ -z "${HOME}" ]; then
  33.             echo "Could not find the correct home directory. Please use the -H option of sudo." >&2
  34.         fi
  35.     fi
  36. fi
  37.  
  38. ##
  39. ## Variables
  40. ##
  41. MOZ_DIST_BIN="/usr/lib/firefox"
  42. MOZ_PROGRAM="${MOZ_DIST_BIN}/firefox-bin"
  43.  
  44. ##
  45. ## Load system and user properties
  46. ##
  47.  
  48. RUNTIME_FIREFOX_DSP="${FIREFOX_DSP}"
  49.  
  50. if [ -f /etc/firefox/firefoxrc ]; then
  51.     . /etc/firefox/firefoxrc
  52. fi
  53.  
  54. if [ -f "${HOME}/.mozilla/firefox/rc" ]; then
  55.     . "${HOME}/.mozilla/firefox/rc"
  56. elif [ -f "${HOME}/.mozilla-firefoxrc" ]; then
  57.     . "${HOME}/.mozilla-firefoxrc"
  58.     echo "Warning: a .mozilla-firefoxrc file has been found in your home directory" >&2
  59.     echo "While it is still supported, it is recommended to move it to" >&2
  60.     echo "\${HOME}/.mozilla/firefox/rc" >&2
  61. fi
  62.  
  63. if [ "x${MOZ_DISABLE_PANGO}" = x ]; then
  64.     if egrep '^(bn|gu|hi|kn|ml|mr|ne|pa|ta|te)_' \
  65.     /var/lib/locales/supported.d/*[^~] >/dev/null 2>&1; then
  66.     MOZ_DISABLE_PANGO=0
  67.     else
  68.     MOZ_DISABLE_PANGO=1
  69.     fi
  70.     export MOZ_DISABLE_PANGO
  71. fi
  72. if [ "x${MOZ_DISABLE_PANGO}" = x0 ]; then
  73.     unset MOZ_DISABLE_PANGO
  74. fi
  75.  
  76. if [ "${RUNTIME_FIREFOX_DSP}" ]; then
  77.     FIREFOX_DSP="${RUNTIME_FIREFOX_DSP}"
  78. fi
  79.  
  80. if [ -z "${FIREFOX_DSP}" ]; then
  81.     #FIREFOX_DSP="auto"
  82.     FIREFOX_DSP="none"
  83.     # esddsp is dreadful, see https://launchpad.net/malone/bugs/29760
  84. fi
  85.  
  86. ##
  87. ## find /dev/dsp handler
  88. ##
  89.  
  90. if [ "${FIREFOX_DSP}" = "auto" ]; then
  91.     FIREFOX_DSP=
  92.     if [ -n "${AUDIOSERVER}" ]; then
  93.         # do not prevent using other wrappers if $AUDIOSERVER was set up
  94.         # unintentionally or audiooss is not available
  95.         if type audiooss >/dev/null 2>&1; then
  96.             FIREFOX_DSP=audiooss
  97.         fi
  98.     fi
  99.     if pgrep -u `id -u` esd >/dev/null 2>&1; then 
  100.         FIREFOX_DSP=esddsp 
  101.     elif pgrep -u `id -u` arts >/dev/null 2>&1; then 
  102.         FIREFOX_DSP=artsdsp 
  103.     elif [ -x /usr/bin/aoss -a -d /proc/asound ] ; then
  104.         FIREFOX_DSP=aoss
  105.     fi
  106. elif [ "${FIREFOX_DSP}" = "none" ]; then
  107.     FIREFOX_DSP=
  108. fi
  109.  
  110. ##
  111. ## Set LD_LIBRARY_PATH
  112. ##
  113. EXTENT_LD_LIB_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:/usr/lib/mozilla-firefox/plugins
  114. if [ "${LD_LIBRARY_PATH}" ]; then
  115.     LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH}:${LD_LIBRARY_PATH}
  116. else
  117.     LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH}
  118. fi
  119.  
  120. export LD_LIBRARY_PATH
  121.  
  122. MOZ_PLUGIN_PATH=/usr/lib/mozilla-firefox/plugins${MOZ_PLUGIN_PATH+":$MOZ_PLUGIN_PATH"}
  123. export MOZ_PLUGIN_PATH
  124.  
  125. # Set XPSERVERLIST if not set yet for XPrint support, or complain.
  126.  
  127. #if [ -z "${XPSERVERLIST}" ]; then
  128. #    if [ -x /etc/init.d/xprint ]; then
  129. #        XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist`
  130. #        export XPSERVERLIST
  131. #    else
  132. #        echo -e "Warning: \${XPSERVERLIST} not set and /etc/init.d/xprint not found;\nprinting will not work.\nPlease install the xprt-xprintorg package" >&2
  133. #    fi  
  134. #fi
  135.  
  136. verbose () {
  137.     if [ "${VERBOSE}" ]; then
  138.         echo $@
  139.     fi
  140. }
  141.  
  142. echo_vars () {
  143.     if [ "${VERBOSE}" ]; then
  144.       for var in "$@"; do
  145.           echo "$var=`eval echo \\${$var}`"
  146.       done
  147.     fi
  148. }
  149.     
  150. # exec wrapper for verbosity
  151. exec_verbose () {
  152.     verbose Running: $@
  153.     exec "$@"
  154. }
  155.  
  156. # exec wrapper for verbosity
  157. run_verbose () {
  158.     verbose Running: $@
  159.     "$@"
  160. }
  161.  
  162. # OK, here's where all the real work gets done
  163.  
  164. # parse command line
  165. APPLICATION_ID=firefox
  166. VERBOSE=
  167. DEBUG=0
  168. DEBUGGER=
  169. first=1
  170. opt=
  171. for arg in "$@"; do
  172.     if [ ${first} -eq 1 ]; then
  173.         set dummy
  174.         first=0
  175.     fi
  176.  
  177.     case "${arg}" in
  178.         -a | --display | -contentLocale | -UILocale | -remote | --debugger | -height | -width | -chrome | -P | -CreateProfile)
  179.             prev=${arg}
  180.             continue
  181.         ;;
  182.     esac
  183.     
  184.     if [ "${prev}" ]; then
  185.         case "${prev}" in
  186.             -a)
  187.                 APPLICATION_ID="${arg}"
  188.                 ;;
  189.             -P|-CreateProfile)
  190.                 case "${arg}" in
  191.                 default)    APPLICATION_ID=firefox ;;
  192.                 *)          APPLICATION_ID=firefox--"${arg}" ;;
  193.                 esac
  194.                 MOZ_NO_REMOTE=1
  195.                 export MOZ_NO_REMOTE
  196.                 set "$@" "${prev}" "${arg}"
  197.                 ;;
  198.             --display)
  199.                 CMDLINE_DISPLAY="${arg}"
  200.                 set "$@" --display "${arg}"
  201.                 ;;
  202.             -remote)
  203.                 set "$@" -remote "${arg}"
  204.                 ;;
  205.             --debugger)
  206.                 DEBUGGER="${arg}"
  207.                 DEBUG=1
  208.                 ;;
  209.             *)
  210.                 set "$@" "${prev}" "${arg}"
  211.                 ;;
  212.         esac
  213.         prev=
  214.     elif [ "${arg}" ]; then
  215.         case "$arg" in
  216.             --verbose | -V)
  217.                 VERBOSE=1
  218.                 ;;
  219.             --display=*)
  220.                 CMDLINE_DISPLAY=`echo ${arg} | sed 's/^--display=//'`
  221.                 set "$@" "${arg}"
  222.                 ;;
  223.             -g | -debug)
  224.                 DEBUG=1
  225.                 ;;
  226.             -no-remote)
  227.                 MOZ_NO_REMOTE=1
  228.                 export MOZ_NO_REMOTE
  229.                 ;;
  230.             -ProfileManager)
  231.                 MOZ_NO_REMOTE=1
  232.                 export MOZ_NO_REMOTE
  233.                 APPLICATION_ID="unique--`uname -n`--$$"
  234.                 set "$@" "${arg}"
  235.                 ;;
  236.             -*)
  237.                 set "$@" "${arg}"
  238.                 ;;
  239.             *)
  240.                 if [ -z "${opt}" ]; then
  241.                     opt="${arg}"
  242.                     # check to make sure that the url contains at least a :/ in it.
  243.                     echo ${opt} | grep -e ':/' 2>/dev/null > /dev/null
  244.                     RETURN_VAL=$?
  245.                     if [ "${RETURN_VAL}" -eq 1 ]; then
  246.                     # if it doesn't begin with a '/' and it exists when the pwd is
  247.                     # prepended to it then append the full path
  248.                         echo ${opt} | grep -e '^/' 2>/dev/null > /dev/null
  249.                         if [ "$?" -ne "0" ] && [ -e "`pwd`/${opt}" ]; then
  250.                             opt="`pwd`/${opt}"
  251.                         fi
  252.                         # Make it percent-encoded and prepend file:// if it is a valid file
  253.                         if [ -e "${opt}" ]; then
  254.                           opt="file://$( echo -n "${opt}" | perl -pe "s/([^a-zA-Z0-9-._~\!\\\$&'()*+,=:@\/])/'%'.unpack('H2',\$1)/ge" )"
  255.                         fi
  256.                     fi
  257.                     set "$@" "${opt}"
  258.                 else
  259.                     set "$@" "${arg}"
  260.                 fi
  261.                 ;;
  262.         esac
  263.     fi
  264. done
  265.  
  266. set "$@" "-a" "${APPLICATION_ID}"
  267.  
  268. if [ $# -ne 0 ]; then
  269.     shift
  270. fi
  271. OPTIONS="$@"
  272.  
  273. if [ ${DEBUG} -eq 1 ]; then
  274.     if [ "${DEBUGGER}" = "" ]; then
  275.         DEBUGGER=gdb
  276.     fi
  277.     TMPFILE=`mktemp -t firefox_argsXXXXXX`
  278.     echo set args "$@" > ${TMPFILE}
  279.     case "${DEBUGGER}" in
  280.         gdb)
  281.             run_verbose gdb "${MOZ_PROGRAM}" -x ${TMPFILE}
  282.             ;;
  283.         ddd)
  284.             run_verbose ddd --debugger "gdb -x ${TMPFILE}" "${MOZ_PROGRAM}"
  285.             ;;
  286.         *)
  287.             run_verbose ${DEBUGGER} "${MOZ_PROGRAM}" "$@"
  288.             ;;
  289.     esac
  290.     rm ${TMPFILE}
  291.     exit
  292. fi
  293.  
  294. echo_vars FIREFOX_DSP APPLICATION_ID CMDLINE_DISPLAY DISPLAY \
  295.           OPTIONS DEBUG DEBUGGER MOZ_DISABLE_PANGO MOZ_NO_REMOTE
  296.  
  297. if type "${FIREFOX_DSP}" > /dev/null 2>&1; then
  298.     MOZ_PROGRAM="${FIREFOX_DSP} ${MOZ_PROGRAM}"
  299. fi
  300.  
  301. exec_verbose ${MOZ_PROGRAM} "$@"
  302.