#!/bin/sh

(APPNAME="uCANConnect"
DISPLAYNAME="uCANConnect"
INSTPATH="/Applications/${DISPLAYNAME}"
BINLOCATION="${APPNAME}.app/Contents/MacOS"

# Get pid and the command of the currently running Installer. It should be our 
# Installer. And return the pid of the Installer. When the pid is not found 
# via pid the Installer is finished.
pid=`ps axww -o "pid,command" | sed -nEe "/\/Installer.app\//s/^ *([0-9]+) .+/\1/p"`

# While Installer is running sleep.
# When the Installer ist not running anymore execute the cardswitcher
while [ "0" != `ps -p "$pid" | grep "^ *$pid" | wc -l` ] ; do
	sleep 1
done

"${INSTPATH}/${BINLOCATION}/CardSwitcher") &

exit 0