source: pkg/kev/main/iceweasel/trunk/debian/iceweasel-runner @ 5919

Revision 5919, 5.1 KB checked in by alanbach-guest, 4 years ago (diff)

[svn-inject] Applying Debian modifications to trunk

Line 
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##
26if [ "${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
36fi
37
38##
39## Variables
40##
41MOZ_DIST_BIN="/usr/lib/iceweasel"
42MOZ_PROGRAM="${MOZ_DIST_BIN}/firefox-bin"
43MOZ_APP_LAUNCHER=/usr/bin/iceweasel
44export MOZ_APP_LAUNCHER
45
46##
47## Load system and user properties
48##
49
50RUNTIME_ICEWEASEL_DSP="${FIREFOX_DSP}"
51if [ "${ICEWEASEL_DSP}" ] ; then
52    RUNTIME_ICEWEASEL_DSP="${ICEWEASEL_DSP}"
53fi
54
55if [ -f /etc/iceweasel/iceweaselrc ]; then
56    . /etc/iceweasel/iceweaselrc
57fi
58
59if [ -f "${HOME}/.mozilla/firefox/rc" ]; then
60    . "${HOME}/.mozilla/firefox/rc"
61elif [ -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
66fi
67
68if [ "${RUNTIME_ICEWEASEL_DSP}" ]; then
69    ICEWEASEL_DSP="${RUNTIME_ICEWEASEL_DSP}"
70fi
71
72if [ -z "${ICEWEASEL_DSP}" ]; then
73    ICEWEASEL_DSP="none"
74fi
75
76##
77## find /dev/dsp handler
78##
79
80if [ "${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
96elif [ "${ICEWEASEL_DSP}" = "none" ]; then
97    ICEWEASEL_DSP=
98fi
99
100##
101## Set LD_LIBRARY_PATH
102##
103EXTENT_LD_LIB_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:/usr/lib/mozilla-firefox/plugins
104if [ "${LD_LIBRARY_PATH}" ]; then
105    LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH}:${LD_LIBRARY_PATH}
106else
107    LD_LIBRARY_PATH=${EXTENT_LD_LIB_PATH}
108fi
109
110export LD_LIBRARY_PATH
111
112EXTENT_MOZ_PLUGIN_PATH=/usr/lib/mozilla-firefox/plugins
113if [ "${MOZ_PLUGIN_PATH}" ]; then
114    MOZ_PLUGIN_PATH=${EXTENT_MOZ_PLUGIN_PATH}:${MOZ_PLUGIN_PATH}
115else
116    MOZ_PLUGIN_PATH=${EXTENT_MOZ_PLUGIN_PATH}
117fi
118
119export MOZ_PLUGIN_PATH
120
121verbose () {
122    if [ "${VERBOSE}" ]; then
123        echo $@
124    fi
125}
126
127echo_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
136exec_verbose () {
137    verbose Running: $@
138    exec "$@"
139}
140
141# exec wrapper for verbosity
142run_verbose () {
143    verbose Running: $@
144    "$@"
145}
146
147# OK, here's where all the real work gets done
148
149# parse command line
150VERBOSE=
151DEBUG=0
152DEBUGGER=
153first=1
154prev=
155for 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
181done
182
183if [ $# -ne 0 ]; then
184    shift
185fi
186OPTIONS="$@"
187
188echo_vars ICEWEASEL_DSP OPTIONS DEBUG DEBUGGER
189
190if [ ${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
209fi
210
211if type "${ICEWEASEL_DSP}" > /dev/null 2>&1; then
212    MOZ_PROGRAM="${ICEWEASEL_DSP} ${MOZ_PROGRAM}"
213fi
214
215exec_verbose ${MOZ_PROGRAM} "$@"
Note: See TracBrowser for help on using the repository browser.