aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/macosx/Resources/script
blob: ff35f1a76a5b7ab1a1921d6b35de68ba12523ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
#
# Author: Aaron Voisine <aaron@voisine.org>
# Wireshark (Inkscape) Modifications: Michael Wybrow <mjwybrow@users.sourceforge.net>

CWD="`dirname \"$0\"`"

# System version: 3 for Panther, 4 for Tiger, 5 for Leopard
export VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`

# On Leopard, X11.app is installed by default, and will be started
# automatically via launchd.  On older systems, we need to start
# X11 ourself.

# For Panther and Tiger, start X11
if [[ $VERSION -le 4 ]]; then
	# FIXME apparently this removes the xterm that starts with X
	# from xinitrc but when is it really used? Should we modify
	# the .xinitrc of the user without warning?
	ps -wx -ocommand | grep -e '[X]11' > /dev/null
	if [ "$?" != "0" -a ! -f "${HOME}/.xinitrc" ]; then
	    echo "rm -f \"${HOME}/.xinitrc\"" > "${HOME}/.xinitrc"
	    sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> "${HOME}/.xinitrc"
	fi

	# Start X11 and get DISPLAY
	cp -f "$CWD/bin/getdisplay.sh" /tmp/
	rm -f /tmp/display.$UID
	open-x11 /tmp/getdisplay.sh || \
	open -a XDarwin /tmp/getdisplay.sh || \
	echo ":0" > /tmp/display.$UID

	while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do
	    sleep 1
	done
	export DISPLAY="`cat /tmp/display.$UID`"

	ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
fi


# Warn the user about time-consuming generation of fontconfig caches.
test -f "${HOME}/.wireshark/.fccache-new" || exit 12


BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`"
cd "$BASE"
exec "$CWD/bin/wireshark" "$@"
# TODO examine wether it would be wisest to move the code from wireshark shell
# script and getdisplay.sh to here and only keep the real binary in bin. This
# may make things easier on Leopard and may also help using Wireshark on the
# command line