Posted on 08-24-2014 02:11 AM
I'm trying to automate the reimage and deployment of machines. I'd like to automate as much as possible.
I'm imaging the machines with DeployStudio and I can install a package that will run on first boot.
Built the package with composer with nothing in it other than a postinstall script with the following in the script:
#########
#!/bin/sh
## postinstall
/usr/sbin/softwareupdate -a -i && /sbin/reboot
#########
Testing this package on it's own in a vm. Just running the command in a script file only takes a few minutes. It updates safari, and itunes.
Then i roll back the snapshot and run the package it never finishes.
Can anyone see what i'm missing?
Does anyone know if i need to fill out or even keep the following which comes in the script?
pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3
Posted on 08-24-2014 08:29 AM
Since you're imaging the machines with DeployStudio, DeployStudio includes a Software Update workflow task that does exactly what you're trying to accomplish. I'd recommend taking a look at it and seeing how it best fits into your workflow.
Posted on 08-25-2014 02:32 PM
How did i not notice that! Thanks!
Posted on 08-25-2014 02:44 PM
@mcparlandj - Yeah, as mentioned, using the default workflow provided by DS will be the best way to do this.
However, to go back and hopefully provide a solution to your original issue, which is, "why the heck doesn't the 'postinstall' script in my pkg run?", I can tell you that, for reasons I just don't know, I've also run into a lot of problems getting postinstall scripts in flat Apple packages to run. For whatever reason, they just seem extremely flaky.
The solution is to use the older bundle style package format (you can switch to those in Composer's preferences) and use the "postflight" script format instead. These seem to work pretty much 100% of the time, assuming your syntax is correct of course. postflight is not supported with flat packages, so you do need to use the older bundle style for those.
If I knew why the postinstall didn't work with flat packages. I'd surely post about it here, but its a mystery to me. I can't tell if its a bug in Composer's implementation of it, or a problem Apple needs to address.
Also, you can safely leave all those pathTo variables in any scripts. They're there more for reminder purposes than anything else.
Anyway, hope that helps.
Posted on 08-25-2014 11:28 PM
That actually helped a lot! Time to tinker some more. Thanks!
Posted on 08-26-2014 03:03 AM
I have a tool for building payload-free packages, where I haven't seen issues with the postinstall script working properly. It's available from here:
Posted on 08-26-2014 06:25 AM
I can tell you that, for reasons I just don't know, I've also run into a lot of problems getting postinstall scripts in flat Apple packages to run. For whatever reason, they just seem extremely flaky. ... If I knew why the postinstall didn't work with flat packages. I'd surely post about it here, but its a mystery to me. I can't tell if its a bug in Composer's implementation of it, or a problem Apple needs to address.
I've never had an issue with postinstall scripts running as expected in flat packages. I'd suspect either an issue with Composer, or operator error... (I exclusively use pkgbuild to build flat packages these days)