Posted on 08-13-2014 08:58 PM
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
Posted on 08-13-2014 10:46 PM
Hi @jhbush1973,
We deploy via a DMG, so we uninstall the version that was there before, then push down the new one.
Also, I launch it via a LaunchAgent... This can then be ran post install too.
Oh & I'm doing some big fixes to my fork of ADPassMon.. If that's then version you're using.. Lemme know if anything isn't quite right.
Posted on 08-14-2014 02:06 AM
Tested it this morning actually. Version 2 doesn't seem to change the user password!
Posted on 08-14-2014 02:12 AM
Might be us however ...
Posted on 08-14-2014 04:02 AM
@jhbush1973 can you post the log from a failed attempt to install?
Posted on 08-14-2014 10:17 AM
@stevewood this is the error I get Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “ADPassMon196.pkg”
Posted on 08-14-2014 10:45 AM
@jhbush1973 i'll assume that you already researched that error code online. best practices suggests making sure that the permissions/ownership of each part of your package is set correctly.
one way to ensure that it's not a permission issue is to set things to 777.
you can do this manually via CLI or, if you're using composer, you can click on each folder and sub-folder and file and change permissions with the checkboxes at the bottom. in this case, i created a launchD script and needed to make sure all users had permission to execute, so i changed it to 777.
Posted on 08-14-2014 12:26 PM
The problem is that you're searching for processes that have the name 'ADPassMon', without excluding processes that have to do with the installer. You're excluding the 'grep' process by using the bracket expression, but your .pkg includes the string you're searching for too. Because of that, the script actually kills itself.
Give these a try:
#!/bin/sh
## preinstall
pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3
pid="$(ps axo pid,command | grep "[A]DPassMon.app" | awk '{ print $1 }')"
echo "${pid}"
if [ -n "${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
Posted on 08-15-2014 11:47 AM
I've been looking at this, (sorry for not replying sooner here or via email).
You can just update in whilst it's running.
We just have a dmg that installs the newer version.
When the user then calls the app, it'll launch the needed. No need to stop it.