source: trunk/third/mozilla/xpfe/bootstrap/mozilla.athena.in @ 19321

Revision 19321, 6.3 KB checked in by rbasch, 21 years ago (diff)
On Linux, set LD_ASSUME_KERNEL to 2.4.1, in order to avoid a java crash upon exit.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# $Id: mozilla.athena.in,v 1.4 2003-05-06 22:38:55 rbasch Exp $
4# Mozilla wrapper script for Athena.
5
6# Set up the environment.
7moz_libdir=%MOZAPPDIR%
8if [ -z "$MOZILLA_FIVE_HOME" ]; then
9  MOZILLA_FIVE_HOME=$moz_libdir
10  export MOZILLA_FIVE_HOME
11fi
12
13# mozilla-xremote-client sends a command to a running mozilla using
14# X properties.  Its possible return codes are:
15#   0  success
16#   1  failed to connect to the X server
17#   2  no running window found
18#   3  failed to send command
19#   4  usage error
20moz_remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
21
22# The following lockers need to be attached to run plugins and helper
23# applications.
24lockers="infoagents acro java"
25
26# Plugins (other than the default "null" plugin) live in infoagents.
27plugin_dir=/mit/infoagents/arch/@sys/lib/mozilla/plugins
28
29# Set LD_LIBRARY_PATH
30moz_lib_path=$MOZILLA_FIVE_HOME:$MOZILLA_FIVE_HOME/plugins
31LD_LIBRARY_PATH=$moz_lib_path${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
32export LD_LIBRARY_PATH
33
34case `uname` in
35SunOS)
36  # On Solaris, use the X server's shared memory transport for better
37  # performance.
38  if [ -z "$XSUNTRANSPORT" ]; then
39    XSUNTRANSPORT=shmem
40    XSUNSMESIZE=512
41    export XSUNTRANSPORT XSUNSMESIZE
42  fi
43  ;;
44Linux)
45  # Set LD_ASSUME_KERNEL to avoid a java crash upon exit.
46  LD_ASSUME_KERNEL=2.4.1
47  export LD_ASSUME_KERNEL
48  ;;
49esac
50
51# Append our plugins directory to the plugin path.
52MOZ_PLUGIN_PATH=${MOZ_PLUGIN_PATH:+"$MOZ_PLUGIN_PATH:"}$plugin_dir
53export MOZ_PLUGIN_PATH
54
55# Prompt the user on how to deal with an existing lock file when no
56# running Mozilla window can be found, and take action accordingly.
57# Parameter 1 is the existing profile lock file path.
58# If the function returns, the lock file may have been removed per the
59# user's choice, and the caller should continue.  Or, this process may
60# exit, if the user so chooses.
61dispose_lock () {
62  lock=$1
63  # Extract the IP address and PID from the contents of the symlink.
64  eval `ls -l $lock | awk '{
65    if (split($NF, a, ":") == 2)
66      printf("lock_ip=%s ; lock_pid=%s\n", a[1], a[2]); }'`
67
68  # If we cannot recognize the link contents, just continue.
69  if [ -z "$lock_ip" ]; then
70    return 0
71  fi
72
73  # See if the lock holder is on this machine by comparing IP addresses.
74  my_host=`hostname`
75  if [ "$lock_ip" = "`host $my_host | awk '{ print $NF; }'`" ]; then
76    # Lock is held on this machine. See if the process is running.
77    if kill -0 $lock_pid 2>/dev/null ; then
78      # Lock is held by a running process.
79      :
80    else
81      # Process is no longer running.  Nuke the lock and continue.
82      rm -f $lock
83      return 0
84    fi
85    lock_host="this machine"
86  else
87    # Lock is held on another machine.
88    # Get the host name of the lock holder.
89    lock_host=`host $lock_ip | \
90        sed -n -e 's/^.*domain name pointer \(.*\)$/\1/p' | \
91        sed -e 's/\.*$//' | tr '[A-Z]' '[a-z]'`
92    if [ -z "$lock_host" ]; then
93      lock_host=$lock_ip
94    fi
95  fi
96
97  dialog_text="
98  Your Mozilla profile directory contains a lock file, but no existing 
99  Mozilla window can be detected.  The lock is owned by process $lock_pid 
100  on $lock_host. 
101
102  Note that running multiple instances of Mozilla will likely corrupt 
103  your profile.  But, if you know for certain that this lock file is 
104  stale, i.e. that you are not running Mozilla on $lock_host, 
105  you may choose to delete the lock file and continue. 
106
107  Otherwise, you may choose to continue with the lock file in place, in 
108  which case Mozilla will display its Profile Manager, allowing you to 
109  select or create a different profile (Mozilla will not permit you to 
110  use a profile which it believes to be in use). 
111
112  Or, you can simply exit, leaving the lock file in place. 
113"
114
115  tag=`gdialog --title "Mozilla profile locked" --radiolist "$dialog_text" \
116         60 60 3 \
117         Exit,     "leaving lock file in place"           on  \
118         Continue, "and invoke Mozilla's Profile Manager" off \
119         Delete    "lock file and proceed"                off 2>&1`
120
121  case "$tag" in
122  *Continue*)
123    ;;
124  *Delete*)
125    rm -f $lock
126    ;;
127  *)
128    exit 1
129    ;;
130  esac
131}
132
133# Give a warning if we're running on a dialup machine.
134if [ -x /etc/athena/dialuptype ]; then
135  cat << \EOF
136
137*** PLEASE DO NOT RUN MOZILLA ON THE DIALUPS! ***
138
139Mozilla is a very large and resource-intensive program, and it is
140not appropriate to run it on a dialup machine.
141
142Please run Mozilla on your local machine rather than on a dialup.
143
144Thank you.
145
146EOF
147fi
148
149# Attach needed lockers.
150for locker in $lockers ; do
151  /bin/athena/attach -h -n -q $locker
152done
153
154# If the user specified a profile to use, is otherwise manipulating
155# profiles, or is just looking for help, skip the check for a running
156# Mozilla, and invoke the program now.
157skip_lock_check=false
158case "$1" in
159-P|-*Profile*|-help)
160  exec $MOZILLA_FIVE_HOME/mozilla-bin "$@"
161  ;;
162esac
163
164# See if there is a running instance of Mozilla.
165if $moz_remote "ping()" >/dev/null 2>&1 ; then
166  found_running=true
167else
168  found_running=false
169fi
170
171# If Mozilla is not running, check for a (possibly stale) lock file in
172# the default profile directory.
173if [ $found_running = false ]; then
174  if [ -d $HOME/.mozilla/$USER ]; then
175    profdir=$HOME/.mozilla/$USER
176  else
177    profdir=$HOME/.mozilla/default
178  fi
179  if [ -d "$profdir" ]; then
180    for lock in $profdir/????????.slt/lock ; do
181      if [ -h $lock ]; then
182        # The profile is locked.  Ask the user how to deal with it.
183        dispose_lock $lock
184        break
185      fi
186    done
187  fi
188fi
189
190# Handle the case where no argument was given.  If there is a running
191# instance, try to open a new window.  Otherwise, run the standard
192# binary.
193if [ $# -eq 0 ]; then
194  if [ "$found_running" = true ]; then
195    exec $moz_remote "xfeDoCommand(openBrowser)"
196  else
197    exec $MOZILLA_FIVE_HOME/mozilla-bin
198  fi
199fi
200
201# Examine the argument to see if we were given a URL or filename.
202case "$1" in
203-*)
204  # No URL argument given.
205  url=
206  ;;
207*:/*|/*)
208  # Looks like a URL or absolute path.
209  url="$1"
210  ;;
211*)
212  # Handle a relative path.
213  if [ -e "$1" ]; then
214    url="`pwd`/$1"
215  else
216    url="$1"
217  fi
218  ;;
219esac
220
221# If there is a running instance, and we have a URL argument, tell
222# Mozilla to open the URL in a new window.  Otherwise, start the
223# standard binary with the given arguments.
224if [ "$found_running" = true -a -n "$url" ]; then
225  exec $moz_remote "openURL($url,new-window)"
226fi
227exec $MOZILLA_FIVE_HOME/mozilla-bin "$@"
Note: See TracBrowser for help on using the repository browser.