Posted on 09-04-2019 01:17 PM
Hey everyone not sure if i worded that properly but looking to create a preinstall script that installs and runs Lotus Notes uninstall silently in the background and installs Lotus Notes 10 after its down.
i created the package with composer yet im stuck on what's next i added a preinstall script that's built in yet don't know how to edit it properly
Posted on 09-04-2019 05:59 PM
@JayD I’m not sure how to do the uninstall itself, but to write that you just delete those 4 variables and write the script how you want. When you’re done just click on a different part of the pkg and it’ll ask if you want to save it.
Posted on 09-04-2019 08:31 PM
Also your package is going to drop all those files on the root level of the drive. You probably want to put them in a folder in /tmp or similar if they are only needed during the uninstall / install process.
You can create this in the PKG by putting the files you want in that location, then dragging them from there to the PKG in Composer.
Posted on 09-05-2019 12:00 AM
you should put those temporary things to /tmp like Look said. Also, you need to test if the uninstaller is executable with root rights. In the POST-Install you should try to run the binary itself from the uninstaller app - similar to this below. After that you could try to install the pkg. Thereafter you should clean up your mess ;)
#!/bin/sh
#uninstall the app with the recommended tool...
/tmp/MyPackageName/Uninstaller.app/Contents/MacOS/uninstaller
sleep 5
#installing fancy stuff
/usr/sbin/installer -pkg /tmp/MyPackage/Name/IBM Lotus Notes.pkg -target /
#moving stuff to their destinations...
cp /tmp/MyPackageName/license/ /Users/Shared/license
#cleaning up the mess
rm -R /tmp/MyPackageName
exit 0
If the Uninstaller needs an active user session, you should consider using "Packages" - there is a nice tutorial from rtrouton on his blog
https://derflounder.wordpress.com/2014/02/20/deploying-sophos-anti-virus-for-mac-os-x-9-x/
Posted on 09-06-2019 11:26 AM
Posted on 09-06-2019 11:32 AM
I would actually do all of this in a postflight/postinstall script using Packages. Use the PKG to place all of the files you need in a place in /tmp, then the postflight script does the heavy lifting (run the uninstall, then install the new version afterwards).
Posted on 09-10-2021 07:00 AM
While this thread is two years old and the issue is likely long since solved, I'll add this for posterity anyway, since someone else might come across it later. The original poster mentioned that the package will be distributed with Munki. With Munki, you can include the uninstall script directly in the pkginfo file as a preinstall_script for the installer without needing to create a custom package with Composer or other tools. This method offers more flexibility for future changes since the script exists outside of the package (i.e. you do not need to modify the package to change the script).
makepkginfo --preinstall_script /path/to/a/script
https://github.com/munki/munki/wiki/Pre-And-Postinstall-Scripts
Munki can coexist with Jamf Pro or any other MDM.