michael@0: #!/bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ## michael@0: ## Usage: michael@0: ## michael@0: ## $ mozilla [args] michael@0: ## michael@0: ## This script is meant to run the application binary from mozilla/dist/bin. michael@0: ## michael@0: ## The script will setup all the environment voodoo needed to make michael@0: ## the application binary to work. michael@0: ## michael@0: michael@0: #uncomment for debugging michael@0: #set -x michael@0: michael@0: moz_libdir=%MOZAPPDIR% michael@0: michael@0: # Use run-mozilla.sh in the current dir if it exists michael@0: # If not, then start resolving symlinks until we find run-mozilla.sh michael@0: found=0 michael@0: progname="$0" michael@0: curdir=`dirname "$progname"` michael@0: progbase=`basename "$progname"` michael@0: run_moz="$curdir/run-mozilla.sh" michael@0: if test -x "$run_moz"; then michael@0: dist_bin="$curdir" michael@0: found=1 michael@0: else michael@0: here=`/bin/pwd` michael@0: while [ -h "$progname" ]; do michael@0: bn=`basename "$progname"` michael@0: cd `dirname "$progname"` michael@0: # Resolve symlink of dirname michael@0: cd `/bin/pwd` michael@0: progname=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' ` michael@0: progbase=`basename "$progname"` michael@0: if [ ! -x "$progname" ]; then michael@0: break michael@0: fi michael@0: curdir=`dirname "$progname"` michael@0: run_moz="$curdir/run-mozilla.sh" michael@0: if [ -x "$run_moz" ]; then michael@0: cd "$curdir" michael@0: dist_bin=`/bin/pwd` michael@0: run_moz="$dist_bin/run-mozilla.sh" michael@0: found=1 michael@0: break michael@0: fi michael@0: done michael@0: cd "$here" michael@0: fi michael@0: if [ $found = 0 ]; then michael@0: # Check default compile-time libdir michael@0: if [ -x "$moz_libdir/run-mozilla.sh" ]; then michael@0: dist_bin="$moz_libdir" michael@0: run_moz="$moz_libdir/run-mozilla.sh" michael@0: else michael@0: echo "Cannot find %MOZ_APP_DISPLAYNAME% runtime directory. Exiting." michael@0: exit 1 michael@0: fi michael@0: fi michael@0: michael@0: script_args="" michael@0: debugging=0 michael@0: MOZILLA_BIN="${progbase}-bin" michael@0: michael@0: if [ "$OSTYPE" = "beos" ]; then michael@0: mimeset -F "$MOZILLA_BIN" michael@0: fi michael@0: michael@0: pass_arg_count=0 michael@0: while [ $# -gt $pass_arg_count ] michael@0: do michael@0: case "$1" in michael@0: -p | --pure | -pure) michael@0: MOZILLA_BIN="${MOZILLA_BIN}.pure" michael@0: shift michael@0: ;; michael@0: -g | --debug) michael@0: script_args="$script_args -g" michael@0: debugging=1 michael@0: shift michael@0: ;; michael@0: -d | --debugger) michael@0: script_args="$script_args -d $2" michael@0: shift 2 michael@0: ;; michael@0: *) michael@0: # Move the unrecognized argument to the end of the list. michael@0: arg="$1" michael@0: shift michael@0: set -- "$@" "$arg" michael@0: pass_arg_count=`expr $pass_arg_count + 1` michael@0: ;; michael@0: esac michael@0: done michael@0: michael@0: if [ $debugging = 1 ] michael@0: then michael@0: echo $dist_bin/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN "$@" michael@0: fi michael@0: exec "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@" michael@0: # EOF.