| 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 iceweasel 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 shouldn't really run Iceweasel through sudo WITHOUT the -H option." >&2 |
|---|
| 30 | echo "Continuing as if you used 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/iceweasel" |
|---|
| 42 | MOZ_PROGRAM="${MOZ_DIST_BIN}/firefox-bin" |
|---|
| 43 | MOZ_APP_LAUNCHER=/usr/bin/iceweasel |
|---|
| 44 | export MOZ_APP_LAUNCHER |
|---|
| 45 | |
|---|
| 46 | ## |
|---|
| 47 | ## Load system and user properties |
|---|
| 48 | ## |
|---|
| 49 | |
|---|
| 50 | RUNTIME_ICEWEASEL_DSP="${FIREFOX_DSP}" |
|---|
| 51 | if [ "${ICEWEASEL_DSP}" ] ; then |
|---|
| 52 | RUNTIME_ICEWEASEL_DSP="${ICEWEASEL_DSP}" |
|---|
| 53 | fi |
|---|
| 54 | |
|---|
| 55 | if [ -f /etc/iceweasel/iceweaselrc ]; then |
|---|
| 56 | . /etc/iceweasel/iceweaselrc |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | if [ -f "${HOME}/.mozilla/firefox/rc" ]; then |
|---|
| 60 | . "${HOME}/.mozilla/firefox/rc" |
|---|
| 61 | elif [ -f "${HOME}/.mozilla-firefoxrc" ]; then |
|---|
| 62 | . "${HOME}/.mozilla-firefoxrc" |
|---|
| 63 | echo "Warning: a .mozilla-firefoxrc file has been found in your home directory" >&2 |
|---|
| 64 | echo "While it is still supported, it is recommended to move it to" >&2 |
|---|
| 65 | echo "\${HOME}/.mozilla/firefox/rc" >&2 |
|---|
| 66 | fi |
|---|
| 67 | |
|---|
| 68 | if [ "${RUNTIME_ICEWEASEL_DSP}" ]; then |
|---|
| 69 | ICEWEASEL_DSP="${RUNTIME_ICEWEASEL_DSP}" |
|---|
| 70 | fi |
|---|
| 71 | |
|---|
| 72 | if [ -z "${ICEWEASEL_DSP}" ]; then |
|---|
| 73 | ICEWEASEL_DSP="none" |
|---|
| 74 | fi |
|---|
| 75 | |
|---|
| 76 | ## |
|---|
| 77 | ## find /dev/dsp handler |
|---|
| 78 | ## |
|---|
| 79 | |
|---|
| 80 | if [ "${ICEWEASEL_DSP}" = "auto" ]; then |
|---|
| 81 | ICEWEASEL_DSP= |
|---|
| 82 | if [ -n "${AUDIOSERVER}" ]; then |
|---|
| 83 | # do not prevent using other wrappers if $AUDIOSERVER was set up |
|---|
| 84 | # unintentionally or audiooss is not available |
|---|
| 85 | if type audiooss >/dev/null 2>&1; then |
|---|
| 86 | ICEWEASEL_DSP=audiooss |
|---|
| 87 | fi |
|---|
| 88 | fi |
|---|
| 89 | if pgrep -u `id -u` esd >/dev/null 2>&1; then |
|---|
| 90 | ICEWEASEL_DSP=esddsp |
|---|
| 91 | elif pgrep -u `id -u` arts >/dev/null 2>&1; then |
|---|
| 92 | ICEWEASEL_DSP=artsdsp |
|---|
| 93 | elif [ -x /usr/bin/aoss ] && [ -d /proc/asound ] ; then |
|---|
| 94 | ICEWEASEL_DSP=aoss |
|---|
| 95 | fi |
|---|
| 96 | elif [ "${ICEWEASEL_DSP}" = "none" ]; then |
|---|
| 97 | ICEWEASEL_DSP= |
|---|
| 98 | fi |
|---|
| 99 | |
|---|
| 100 | ## |
|---|
| 101 | ## Set LD_LIBRARY_PATH |
|---|
| 102 | ## |
|---|
| 103 | EXTENT_LD_LIB_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:/usr/lib/mozilla-firefox/plugins |
|---|
| 104 | if [ "${LD_LIBRARY_PATH}" ]; then |
|---|
| 105 | LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH}:${LD_LIBRARY_PATH} |
|---|
| 106 | else |
|---|
| 107 | LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH} |
|---|
| 108 | fi |
|---|
| 109 | |
|---|
| 110 | export LD_LIBRARY_PATH |
|---|
| 111 | |
|---|
| 112 | EXTENT_MOZ_PLUGIN_PATH=/usr/lib/mozilla-firefox/plugins |
|---|
| 113 | if [ "${MOZ_PLUGIN_PATH}" ]; then |
|---|
| 114 | MOZ_PLUGIN_PATH=${EXTENT_MOZ_PLUGIN_PATH}:${MOZ_PLUGIN_PATH} |
|---|
| 115 | else |
|---|
| 116 | MOZ_PLUGIN_PATH=${EXTENT_MOZ_PLUGIN_PATH} |
|---|
| 117 | fi |
|---|
| 118 | |
|---|
| 119 | export MOZ_PLUGIN_PATH |
|---|
| 120 | |
|---|
| 121 | verbose () { |
|---|
| 122 | if [ "${VERBOSE}" ]; then |
|---|
| 123 | echo $@ |
|---|
| 124 | fi |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | echo_vars () { |
|---|
| 128 | if [ "${VERBOSE}" ]; then |
|---|
| 129 | for var in "$@"; do |
|---|
| 130 | echo "$var=`eval echo \\${$var}`" |
|---|
| 131 | done |
|---|
| 132 | fi |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | # exec wrapper for verbosity |
|---|
| 136 | exec_verbose () { |
|---|
| 137 | verbose Running: $@ |
|---|
| 138 | exec "$@" |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | # exec wrapper for verbosity |
|---|
| 142 | run_verbose () { |
|---|
| 143 | verbose Running: $@ |
|---|
| 144 | "$@" |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | # OK, here's where all the real work gets done |
|---|
| 148 | |
|---|
| 149 | # parse command line |
|---|
| 150 | VERBOSE= |
|---|
| 151 | DEBUG=0 |
|---|
| 152 | DEBUGGER= |
|---|
| 153 | first=1 |
|---|
| 154 | prev= |
|---|
| 155 | for arg in "$@"; do |
|---|
| 156 | if [ ${first} -eq 1 ]; then |
|---|
| 157 | set dummy |
|---|
| 158 | first=0 |
|---|
| 159 | fi |
|---|
| 160 | |
|---|
| 161 | if [ "${prev}" ]; then # That can only be --debugger |
|---|
| 162 | DEBUGGER="${arg}" |
|---|
| 163 | prev= |
|---|
| 164 | else |
|---|
| 165 | case "$arg" in |
|---|
| 166 | --verbose | -V) |
|---|
| 167 | VERBOSE=1 |
|---|
| 168 | ;; |
|---|
| 169 | -g | -debug) |
|---|
| 170 | DEBUG=1 |
|---|
| 171 | ;; |
|---|
| 172 | --debugger) |
|---|
| 173 | DEBUG=1 |
|---|
| 174 | prev=${arg} |
|---|
| 175 | ;; |
|---|
| 176 | *) |
|---|
| 177 | set "$@" "${arg}" |
|---|
| 178 | ;; |
|---|
| 179 | esac |
|---|
| 180 | fi |
|---|
| 181 | done |
|---|
| 182 | |
|---|
| 183 | if [ $# -ne 0 ]; then |
|---|
| 184 | shift |
|---|
| 185 | fi |
|---|
| 186 | OPTIONS="$@" |
|---|
| 187 | |
|---|
| 188 | echo_vars ICEWEASEL_DSP OPTIONS DEBUG DEBUGGER |
|---|
| 189 | |
|---|
| 190 | if [ ${DEBUG} -eq 1 ]; then |
|---|
| 191 | if [ "${DEBUGGER}" = "" ]; then |
|---|
| 192 | DEBUGGER=gdb |
|---|
| 193 | fi |
|---|
| 194 | TMPFILE=`mktemp -t iceweasel_argsXXXXXX` |
|---|
| 195 | echo set args "$@" > ${TMPFILE} |
|---|
| 196 | case "${DEBUGGER}" in |
|---|
| 197 | gdb) |
|---|
| 198 | run_verbose gdb "${MOZ_PROGRAM}" -x ${TMPFILE} |
|---|
| 199 | ;; |
|---|
| 200 | ddd) |
|---|
| 201 | run_verbose ddd --debugger "gdb -x ${TMPFILE}" "${MOZ_PROGRAM}" |
|---|
| 202 | ;; |
|---|
| 203 | *) |
|---|
| 204 | run_verbose ${DEBUGGER} "${MOZ_PROGRAM}" "$@" |
|---|
| 205 | ;; |
|---|
| 206 | esac |
|---|
| 207 | rm ${TMPFILE} |
|---|
| 208 | exit |
|---|
| 209 | fi |
|---|
| 210 | |
|---|
| 211 | if type "${ICEWEASEL_DSP}" > /dev/null 2>&1; then |
|---|
| 212 | MOZ_PROGRAM="${ICEWEASEL_DSP} ${MOZ_PROGRAM}" |
|---|
| 213 | fi |
|---|
| 214 | |
|---|
| 215 | exec_verbose ${MOZ_PROGRAM} "$@" |
|---|