We have an in house application that runs via a LaunchAgent that we are looking to deploy.
I've successfully packaged up the app along with the plist for the agent, and ensure permissions are correct on everything.
The preinstall script is set to check if the service is running under either the current user (via a defined variable) or under root (which it shouldnt be so this is a safety check) and if either is found to unload the plist as the necessary user (sudo -u $CurrentUser launchctl unload or sudo launchctl unload).
The postinstall script is set to then reload the agent plist as the current user (sudo -u $CurrentUser launchctl load).
Similarly I have an uninstall script that is basically the same as the preinstall script but with the addition of a few rm lines to delete the installed payload.
Both the installer and the uninstaller work fine when run locally on the Mac. As soon as they are put into the Casper and run, the load/unload commands all seem to fail stating that the domain cant be found, despite the fact that the same command if executed as root via Terminal run fine. I've tested running just the separate scripts outside of the package via the JSS and Remote but the same thing happens, nothing works unless its run local.
Any help would be appreciated.