I'm having a problem figuring out some packaging errors. Any idea why these scripts would fail when added to a package? I'm basically just looking to kill the app prior to replacing it. Both scripts work fine when run manually. It's only when they are packaged do they cause the install to fail. Any help is greatly appreciated.
#!/bin/sh
## preinstall
##
## Not supported for flat packages.
pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3
pid=$(ps axo pid,command | grep "[A]DPassMon" | awk '{print $1}')
echo $pid
if [ "$pid" ]; then
kill $pid
else
echo "Does not exist"
fi
if [ -d "$3/Applications/ADPassMon.app" ]; then
rm -rf "$3/Applications/ADPassMon.app"
else
echo "Does not exist"
fi
exit 0
#!/bin/sh
## postinstall
pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3
## Finding local user
user=`ls -l /dev/console | cut -d " " -f 4`
## Launching ADPassMon
sudo -u $user open -a /Applications/ADPassMon.app
exit 0