3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
39 ## $Id: mozilla.in,v 1.4 2008/01/07 23:17:05 reed%reedloden.com Exp $
45 ## This script is meant to run the mozilla-bin binary from either
46 ## mozilla/xpfe/bootstrap or mozilla/dist/bin.
48 ## The script will setup all the environment voodoo needed to make
49 ## the mozilla-bin binary to work.
52 moz_pis_startstop_scripts
()
54 MOZ_USER_DIR
="%MOZ_USER_DIR%"
55 # MOZ_PIS_ is the name space for "Mozilla Plugable Init Scripts"
56 # These variables and there meaning are specified in
57 # mozilla/xpfe/bootstrap/init.d/README
59 MOZ_PIS_MOZBINDIR
="${dist_bin}"
60 MOZ_PIS_SESSION_PID
="$$"
61 MOZ_PIS_USER_DIR
="${MOZ_USER_DIR}"
62 export MOZ_PIS_API MOZ_PIS_MOZBINDIR MOZ_PIS_SESSION_PID MOZ_PIS_USER_DIR
66 for curr_pis
in "${dist_bin}/init.d"/S* "${HOME}/${MOZ_USER_DIR}/init.d"/S
* ; do
67 if [ -x "${curr_pis}" ] ; then
69 *.sh
) .
"${curr_pis}" ;;
70 *) "${curr_pis}" "start" ;;
76 for curr_pis
in "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/init.d"/K
* ; do
77 if [ -x "${curr_pis}" ] ; then
79 *.sh
) .
"${curr_pis}" ;;
80 *) "${curr_pis}" "stop" ;;
86 echo 1>&2 "$0: Internal error in moz_pis_startstop_scripts."
92 #uncomment for debugging
95 moz_libdir
=%MOZAPPDIR
%
98 # Use run-mozilla.sh in the current dir if it exists
99 # If not, then start resolving symlinks until we find run-mozilla.sh
102 curdir
=`dirname "$progname"`
103 progbase
=`basename "$progname"`
105 run_moz
="$curdir/run-mozilla.sh"
106 if test -x "$run_moz"; then
111 while [ -h "$progname" ]; do
112 bn
=`basename "$progname"`
113 cd `dirname "$progname"`
114 progname
=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' `
115 progbase
=`basename "$progname"`
116 if [ ! -x "$progname" ]; then
119 curdir
=`dirname "$progname"`
120 run_moz
="$curdir/run-mozilla.sh"
121 if [ -x "$run_moz" ]; then
130 if [ $found = 0 ]; then
131 # Check default compile-time libdir
132 if [ -x "$moz_libdir/run-mozilla.sh" ]; then
133 dist_bin
="$moz_libdir"
135 echo "Cannot find mozilla runtime directory. Exiting."
142 MOZILLA_BIN
="${progbase}-bin"
143 MOZ_CLIENT_PROGRAM
="$dist_bin/mozilla-xremote-client"
145 run_xremote_client
() {
146 if [ -n "${profile}" ]; then
147 "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" -p "${profile}" "$1"
149 "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "$1"
153 # The following is to check for a currently running instance.
154 # This is taken almost verbatim from the Mozilla RPM package's launch script.
156 run_xremote_client
'ping()' 2>/dev
/null
>/dev
/null
158 if [ $RETURN_VAL -eq 0 ]; then
167 if [ "$OSTYPE" = "beos" ]; then
168 mimeset
-F "$MOZILLA_BIN"
171 ################################################################ Parse Arguments
172 # If there's a command line argument but it doesn't begin with a -
173 # it's probably a url. Try to send it to a running instance.
192 [ "$i" = "${_optLast}" ] && break
193 _optOthers
="${_optOthers} ${i}"
196 #???: needs check if othersopt begin with -* ?
197 if [ `expr "${_optLast}" : '.*:/.*'` -eq 0 -a \( -f "${_optLast}" -o -d "${_optLast}" \) ]; then
198 # Last argument seems to be a local file/directory
199 # Check, if it is absolutely specified (ie. /home/foo/file vs. ./file)
200 # If it is just "relatively" (./file) specified, make it absolutely
201 [ `expr "${_optLast}" : '/.*'` -eq 0 ] && _optLast="file://`pwd`/${_optLast}"
202 elif [ `expr "${_optLast}" : '.*:/.*'` -gt 0 -o -n "${_optOthers}" ]; then #???? like before...
206 # check for -P argument used to select a user profile
209 if [ "$i" = "-P" ]; then
212 elif [ ${_expectProfileName} = 1 ]; then
218 ################################################################ Parse Arguments
220 ########################################################################### Main
221 ALREADY_RUNNING=`check_running
`
223 if [ $ALREADY_RUNNING -eq 1 ]; then
224 # There's an instance already running. Use it.
225 # Any command line args passed in?
226 if [ $# -gt 0 ]; then
227 # There were "some" command line args.
228 if [ ${_USE_EXIST} -eq 1 ]; then
229 # We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-1
232 _remote_cmd="openURL(${_optLast} , new-${_open_type})"
233 run_xremote_client "${_remote_cmd}"
234 unset _remote_cmd _open_type
238 # No command line args. Open new window/tab
239 run_xremote_client "xfeDoCommand(openBrowser)"
243 # Default action - no running instance or _USE_EXIST (${_USE_EXIST}) ! -eq 1
244 ########################################################################### Main
247 while [ $# -gt $pass_arg_count ]
251 MOZILLA_BIN="${MOZILLA_BIN}.pure"
255 script_args="$script_args -g"
260 script_args="$script_args -d $2"
264 # Move the unrecognized argument to the end of the list.
268 pass_arg_count=`expr $pass_arg_count + 1`
275 ## Start addon scripts
276 moz_pis_startstop_scripts "start"
278 if [ $debugging = 1 ]
280 echo $dist_bin/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN "$@"
282 "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
285 ## Stop addon scripts
286 moz_pis_startstop_scripts "stop"