| 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_APP_LAUNCHER="$(which $0)" |
|---|
| 42 | MOZ_DIST_BIN="$(dirname "$(readlink -f "${MOZ_APP_LAUNCHER}")")" |
|---|
| 43 | MOZ_PROGRAM="${MOZ_DIST_BIN}/firefox-bin" |
|---|
| 44 | MOZ_APP_LAUNCHER=/usr/bin/iceweasel |
|---|
| 45 | export MOZ_APP_LAUNCHER |
|---|
| 46 | |
|---|
| 47 | ## |
|---|
| 48 | ## Load system and user properties |
|---|
| 49 | ## |
|---|
| 50 | |
|---|
| 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 | verbose () { |
|---|
| 101 | if [ "${VERBOSE}" ]; then |
|---|
| 102 | echo $@ |
|---|
| 103 | fi |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | echo_vars () { |
|---|
| 107 | if [ "${VERBOSE}" ]; then |
|---|
| 108 | for var in "$@"; do |
|---|
| 109 | echo "$var=`eval echo \\${$var}`" |
|---|
| 110 | done |
|---|
| 111 | fi |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | # exec wrapper for verbosity |
|---|
| 115 | exec_verbose () { |
|---|
| 116 | verbose Running: $@ |
|---|
| 117 | exec "$@" |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | # exec wrapper for verbosity |
|---|
| 121 | run_verbose () { |
|---|
| 122 | verbose Running: $@ |
|---|
| 123 | "$@" |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | # OK, here's where all the real work gets done |
|---|
| 127 | |
|---|
| 128 | # parse command line |
|---|
| 129 | VERBOSE= |
|---|
| 130 | DEBUG=0 |
|---|
| 131 | DEBUGGER= |
|---|
| 132 | first=1 |
|---|
| 133 | prev= |
|---|
| 134 | for arg in "$@"; do |
|---|
| 135 | if [ ${first} -eq 1 ]; then |
|---|
| 136 | set dummy |
|---|
| 137 | first=0 |
|---|
| 138 | fi |
|---|
| 139 | |
|---|
| 140 | if [ "${prev}" ]; then # That can only be --debugger |
|---|
| 141 | DEBUGGER="${arg}" |
|---|
| 142 | prev= |
|---|
| 143 | else |
|---|
| 144 | case "$arg" in |
|---|
| 145 | --verbose | -V) |
|---|
| 146 | VERBOSE=1 |
|---|
| 147 | ;; |
|---|
| 148 | -g | -debug) |
|---|
| 149 | DEBUG=1 |
|---|
| 150 | ;; |
|---|
| 151 | --debugger) |
|---|
| 152 | DEBUG=1 |
|---|
| 153 | prev=${arg} |
|---|
| 154 | ;; |
|---|
| 155 | *) |
|---|
| 156 | set "$@" "${arg}" |
|---|
| 157 | ;; |
|---|
| 158 | esac |
|---|
| 159 | fi |
|---|
| 160 | done |
|---|
| 161 | |
|---|
| 162 | if [ $# -ne 0 ]; then |
|---|
| 163 | shift |
|---|
| 164 | fi |
|---|
| 165 | OPTIONS="$@" |
|---|
| 166 | |
|---|
| 167 | echo_vars ICEWEASEL_DSP OPTIONS DEBUG DEBUGGER |
|---|
| 168 | |
|---|
| 169 | if [ ${DEBUG} -eq 1 ]; then |
|---|
| 170 | if [ "${DEBUGGER}" = "" ]; then |
|---|
| 171 | DEBUGGER=gdb |
|---|
| 172 | fi |
|---|
| 173 | TMPFILE=`mktemp -t iceweasel_argsXXXXXX` |
|---|
| 174 | echo set args "$@" > ${TMPFILE} |
|---|
| 175 | case "${DEBUGGER}" in |
|---|
| 176 | gdb) |
|---|
| 177 | run_verbose gdb "${MOZ_PROGRAM}" -x ${TMPFILE} |
|---|
| 178 | ;; |
|---|
| 179 | ddd) |
|---|
| 180 | run_verbose ddd --debugger "gdb -x ${TMPFILE}" "${MOZ_PROGRAM}" |
|---|
| 181 | ;; |
|---|
| 182 | *) |
|---|
| 183 | run_verbose ${DEBUGGER} "${MOZ_PROGRAM}" "$@" |
|---|
| 184 | ;; |
|---|
| 185 | esac |
|---|
| 186 | rm ${TMPFILE} |
|---|
| 187 | exit |
|---|
| 188 | fi |
|---|
| 189 | |
|---|
| 190 | if type "${ICEWEASEL_DSP}" > /dev/null 2>&1; then |
|---|
| 191 | MOZ_PROGRAM="${ICEWEASEL_DSP} ${MOZ_PROGRAM}" |
|---|
| 192 | fi |
|---|
| 193 | |
|---|
| 194 | exec_verbose ${MOZ_PROGRAM} "$@" |
|---|