#!/bin/sh
#
# Wireshark CLI utility launcher

if [ -z "$WIRESHARK_APP_DIR" ] ; then
	WIRESHARK_APP_DIR="/Applications/Wireshark.app"
fi

if [ ! -d "$WIRESHARK_APP_DIR" ] ; then
	WIRESHARK_APP_DIR=`mdfind "kMDItemCFBundleIdentifier == 'org.wireshark.Wireshark'" | head -n 1`
fi

if [ ! -d "$WIRESHARK_APP_DIR" ] ; then
	echo "Wireshark doesn't appear to be located at $WIRESHARK_APP_DIR."
	echo "Please set WIRESHARK_APP_DIR to its proper location and try again."
	exit 1
fi

APP_NAME=`basename "$0"`
if [ "$APP_NAME" = "wireshark" ] ; then
	APP_NAME=Wireshark
fi
exec "$WIRESHARK_APP_DIR/Contents/MacOS/$APP_NAME" "$@"
