aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/macosx/Resources/bin/wireshark
blob: 358dbf0bcb47d228610ae0e5302a12a378b28d48 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#
# $Id$
#
# Author: Aaron Voisine <aaron@voisine.org>
# Wireshark Modifications:
#	Michael Wybrow <mjwybrow@users.sourceforge.net>
#	Jean-Olivier Irisson <jo.irisson@gmail.com>
#

CWD="`(cd \"\`dirname \\\"$0\\\"\`\"; echo $PWD)`"
# e.g. /Applications/Wireshark.app/Contents/Resources/bin
TOP="`dirname \"$CWD\"`"
# e.g. /Applications/Wireshark.app/Contents/Resources

# We might be exec'ed from wireshark, tshark, dumpcap, or any other binary
# from the Wireshark distribution.
# XXX - Should we verify that we have a valid name?
APPNAME=`basename "$0"`

# Brutally add many things to the PATH. If the directories do not exist, they won't be used anyway.
# People should really use ~/.macosx/environment.plist to set environment variables as explained by Apple:
#	http://developer.apple.com/qa/qa2001/qa1067.html
# but since no one does, we correct this by making the 'classic' PATH additions here:
#	/usr/local/bin which, though standard, doesn't seem to be in the PATH
# 	newer python as recommended by MacPython http://www.python.org/download/mac/
#	Fink
#	MacPorts (former DarwinPorts)
export PATH="/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH"

export DYLD_LIBRARY_PATH="$TOP/lib"

export WIRESHARK_DATA_DIR="$TOP/share/wireshark"
export WIRESHARK_PLUGIN_DIR="$TOP/lib/wireshark/plugins"
export WIRESHARK_PYTHON_DIR="$TOP/lib/wireshark/python"

if [ "$APPNAME" == "wireshark" ] ; then # Apply GUI settings
	# For Panther and Tiger, override the default fontconfig configuration
        # XXX - This apparently isn't needed?
	#if [[ $VERSION -le 4 ]]; then
		export FONTCONFIG_PATH="$TOP/etc/fonts"
	#fi
	export PANGO_RC_FILE="$HOME/.wireshark-etc/pangorc"
	export GTK_IM_MODULE_FILE="$HOME/.wireshark-etc/gtk.immodules"
	export GDK_PIXBUF_MODULE_FILE="$HOME/.wireshark-etc/gdk-pixbuf.loaders"
	export GTK_DATA_PREFIX="$TOP"
	export GTK_EXE_PREFIX="$TOP"
	export GNOME_VFS_MODULE_CONFIG_PATH="$TOP/etc/gnome-vfs-2.0/modules"
	export GNOME_VFS_MODULE_PATH="$TOP/lib/gnome-vfs-2.0/modules"

	# Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
	if [[ ! -e $HOME/.gtkrc-2.0 ]]; then
		# prepare the theme depending on OS X appearance settings
		(
			cd "$TOP/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/"
			./sync_osx_look.sh
			# TODO: make this more robust, probably by integrating this script directly inline here
		)
		export GTK2_RC_FILES="$TOP/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/gtkrc"
	fi

	# TODO: Have to add ".UTF-8" to the LANG since ommiting causes Wireshark
	#       to crash on startup in locale_from_utf8().
	export LANG="`grep \"\`defaults read .GlobalPreferences AppleCollationOrder \
		2>&1\`_\" /usr/share/locale/locale.alias | tail -n1 | sed 's/\./ /' | \
		awk '{print $2}'`.UTF-8"

	# Handle the case where the directory storing Wireshark has a '#' in the name.
	# This '#' needs to be escaped in pango.modules for Pango to work properly.
	ESCAPEDTOP=`echo $TOP | sed 's/#/\\\\\\\\#/'`

	mkdir -p ${HOME}/.wireshark-etc
	sed 's|${HOME}|'"$HOME|g" "$TOP/etc/pango/pangorc" > ${HOME}/.wireshark-etc/pangorc
	sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/pango/pango.modules" \
		> ${HOME}/.wireshark-etc/pango.modules
	cp -f "$TOP/etc/pango/pangox.aliases" ${HOME}/.wireshark-etc/
	sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gtk.immodules" \
		> ${HOME}/.wireshark-etc/gtk.immodules
	sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gdk-pixbuf.loaders" \
		> ${HOME}/.wireshark-etc/gdk-pixbuf.loaders
fi

exec "$CWD/$APPNAME-bin" "$@"